⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uxlssheet.pas

📁 TMS Component Pack Pro v4.2
💻 PAS
📖 第 1 页 / 共 5 页
字号:

procedure TSheet.SetShowGridLines(const Value: boolean);
begin
  if (FWindow2<>nil) then FWindow2.ShowGridLines:=value;
end;

function TSheet.GetShowGridHeaders: boolean;
begin
  if (FWindow2<>nil) then Result:=FWindow2.ShowGridHeaders else Result:=true;
end;

procedure TSheet.SetShowGridHeaders(const Value: boolean);
begin
  if (FWindow2<>nil) then FWindow2.ShowGridHeaders:=value;
end;

function TSheet.GetPrintGridLines: boolean;
begin
  if (FPrintGridLines<>nil) then Result:=FPrintGridLines.Value else Result:=true;
end;

procedure TSheet.SetPrintGridLines(const Value: boolean);
begin
  if (FPrintGridLines<>nil) then FPrintGridLines.Value:=value;
end;

function TSheet.GetPageFooter: WideString;
begin
  if (FPageFooter<>nil) then Result:=FPageFooter.Text else Result:='';
end;

function TSheet.GetPageHeader: WideString;
begin
  if (FPageHeader<>nil) then Result:=FPageHeader.Text else Result:='';
end;

procedure TSheet.SetPageFooter(const Value: WideString);
begin
  SetPageHeaderFooter(FPageFooter, Value);
end;

procedure TSheet.SetPageHeader(const Value: WideString);
begin
  SetPageHeaderFooter(FPageHeader, Value);
end;

function TSheet.GetMargins: TXlsMargins;
var
  t, l: double;
const
  l0: array[0..7]of byte=($FC, $FD, $7E, $BF, $DF, $EF, $E7, $3F);
  t0: array[0..7]of byte=($E0, $EF, $F7, $FB, $FD, $7E, $EF, $3F);
begin
  FillChar(Result, SizeOf(Result), 0);
  move(t0, t ,SizeOf(t));
  move(l0, l ,SizeOf(t));

  if FLeftMargin<>nil then Result.Left:=FLeftMargin.Value else Result.Left:=l;
  if FRightMargin<>nil then Result.Right:=FRightMargin.Value else Result.Right:=l;
  if FTopMargin<>nil then Result.Top:=FTopMargin.Value else Result.Top:=t;
  if FBottomMargin<>nil then Result.Bottom:=FBottomMargin.Value else Result.Bottom:=t;

  if FSetup<> nil then
  begin
    Result.Header:= FSetup.HeaderMargin;
    Result.Footer:= FSetup.FooterMargin;
  end;

end;

procedure TSheet.SetMargins(const Value: TXlsMargins);
begin
  if FLeftMargin=nil then AddMargin(FLeftMargin, xlr_LEFTMARGIN, Value.Left) else FLeftMargin.Value:=Value.Left;
  if FRightMargin=nil then AddMargin(FRightMargin, xlr_RIGHTMARGIN, Value.Right) else FRightMargin.Value:=Value.Right;
  if FTopMargin=nil then AddMargin(FTopMargin, xlr_TOPMARGIN, Value.Top) else FTopMargin.Value:=Value.Top;
  if FBottomMargin=nil then AddMargin(FBottomMargin, xlr_BOTTOMMARGIN, Value.Bottom) else FBottomMargin.Value:=Value.Bottom;

  if FSetup<> nil then
  begin
    FSetup.HeaderMargin:=Value.Header;
    FSetup.FooterMargin:=Value.Footer;
  end;

end;

procedure TSheet.AddMargin(var Margin: TMarginRecord; const aId: integer;
  const Value: extended);
const
  DataSize=SizeOf(Double);
var
  Data: PArrayOfByte;
  i,k, RId: integer;
begin
  //Search for the best position...
  k:=FPrintRecords.Count-1;
  for i:=FPrintRecords.Count-1 downto 0 do
  begin
    RId:=(FPrintRecords[i] as TBaseRecord).Id;
    if (RId=xlr_LEFTMARGIN) or(RId=xlr_RIGHTMARGIN)
       or(RId=xlr_TOPMARGIN) or(RId=xlr_BOTTOMMARGIN)
       or (RId=xlr_VCENTER)or (RId=xlr_DEFAULTROWHEIGHT)then
    begin
      k:=i;
      break;
    end;
  end;
  GetMem(Data, DataSize);
  try
    FPrintRecords.Insert(k +1,TMarginRecord.Create(aId, Data, DataSize));
  except
    FreeMem(Data);
    raise;
  end; //Except
  Margin:=(FPrintRecords[k+1] as TMarginRecord);
  Margin.Value:=Value;
end;

function TSheet.GetSheetZoom: integer;
begin
  if FZoom<>nil then Result:=FZoom.Zoom else Result:=100;
end;

function TSheet.GetIsR1C1: boolean;
begin
  if FRefMode<>nil then Result:=FRefMode.IsR1C1 else Result:=false;
end;

procedure TSheet.SetIsR1C1(const Value: boolean);
begin
  if FRefMode<>nil then FRefMode.IsR1C1:=Value;
end;


procedure TSheet.SetSheetZoom(const Value: integer);
begin
  if FZoom=nil then AddZoomRecord;
  if FZoom=nil then exit;
  FZoom.Zoom:=Value;
end;

procedure TSheet.FreezePanes(const row: integer; const col: integer);
var
  Frost: Boolean;
  row1: integer;
  col1: integer;
begin
  Frost := (row > 0) or (col > 0);
  Window2Frozen := Frost;
  if FWindow2 <> nil then
    FWindow2.IsFrozenButNoSplit := Frost;

  AddOrRemovePane(Frost);
  if FPane = nil then
    exit;

  if row < 1 then row1 := 1 else row1 := row;
  if col < 1 then col1 := 1 else col1 := col;
  FPane.RowSplit := row;
  if FPane.FirstVisibleRow < row1 then
    FPane.FirstVisibleRow := row1;

  FPane.ColSplit := col;
  if FPane.FirstVisibleCol < col1 then
    FPane.FirstVisibleCol := col1;

  FPane.EnsureSelectedVisible;
end;

procedure TSheet.SplitWindow(const xOffset: integer; const yOffset: integer);
var
  Frost: Boolean;
begin
  Frost := (xOffset > 0) or (yOffset > 0);
  Window2Frozen := false;
  if FWindow2 <> nil then
    FWindow2.IsFrozenButNoSplit := false;

  AddOrRemovePane(Frost);
  if FPane = nil then
    exit;

  FPane.RowSplit := yOffset;
  FPane.ColSplit := xOffset;
  if FPane.FirstVisibleRow < 1 then
    FPane.FirstVisibleRow := 1;

  if FPane.FirstVisibleCol < 1 then
    FPane.FirstVisibleCol := 1;

  FPane.EnsureSelectedVisible;
end;

procedure TSheet.GetFrozenPanes(var row, col: integer);
begin
  Row := 0;
  Col := 0;
  if (FPane <> nil) and Window2Frozen then
  begin
    Row := FPane.RowSplit;
    Col := FPane.ColSplit;
  end;
end;

procedure TSheet.GetSplitWindow(var xOffset: integer; var yOffset: integer);
begin
  xOffset := 0;
  yOffset := 0;
  if (FPane <> nil) and not Window2Frozen then
  begin
    xOffset:=FPane.ColSplit;
    yOffset:=FPane.RowSplit;
  end;
end;

function TSheet.GetWindow2Frozen(): Boolean;
begin
  Result := (FWindow2 = nil) or FWindow2.IsFrozen;
end;

procedure TSheet.SetWindow2Frozen(const value: Boolean);
begin
  if FWindow2 <> nil then
  FWindow2.IsFrozen := value;

end;


procedure TSheet.FixCachePointers;
begin
  //Nothing here.
end;

procedure TSheet.LoadCachePointers(const R: TBaseRecord);

begin
  if R = nil then exit;

  if R.Id=xlr_WINDOW2 then FWindow2:=R as TWindow2Record else
  if R.Id=xlr_SCL then FZoom:=R as TSCLRecord else
  if R.Id=xlr_FOOTER then FPageFooter:=R as TPageFooterRecord else
  if R.Id=xlr_HEADER then FPageHeader:=R as TPageHeaderRecord else
  if R.Id=xlr_PRINTGRIDLINES then FPrintGridLines:=R as TPrintGridLinesRecord else

  if R.Id=xlr_LEFTMARGIN then FLeftMargin:=R as TMarginRecord else
  if R.Id=xlr_RIGHTMARGIN then FRightMargin:=R as TMarginRecord else
  if R.Id=xlr_TOPMARGIN then FTopMargin:=R as TMarginRecord else
  if R.Id=xlr_BOTTOMMARGIN then FBottomMargin:=R as TMarginRecord else

  if R.Id=xlr_SETUP then FSetup:=R as TSetupRecord else
  if R.Id=xlr_PLS then FPrinterDriverSettings:=R as TPlsRecord else
  if R.Id=xlr_WSBool then FWsBool:=R as TWsBoolRecord;

  if R.Id=xlr_Pane then FPane := R as TPaneRecord else
  if R.Id=xlr_GUTS then FGuts:=R as TGutsRecord else
  if R.Id=xlr_REFMODE then FRefMode:=R as TRefModeRecord;
end;

function TSheet.TotalRangeSize(const SheetIndex: integer;
  const CellRange: TXlsCellRange): int64;
begin
  Result:= inherited TotalRangeSize(SheetIndex, CellRange);
  if (FCodeName<>nil) then inc(Result, FCodeName.TotalSize);
end;

function TSheet.TotalSize: int64;
begin
  Result:= inherited TotalSize;
  if (FCodeName<>nil) then inc(Result, FCodeName.TotalSize);
end;

function TSheet.GetCodeName: widestring;
begin
  if FCodeName<>nil then Result:=FCodeName.SheetName else Result:='';
end;

procedure TSheet.SetCodeName(const Value: widestring);
begin
  FreeAndNil(FCodeName);
  FCodeName:=TCodeNameRecord.CreateNew(Value);
end;


procedure TSheet.Clear;
begin
  inherited;
  //don't FWorkbookGlobals:=nil;
  FWindow2:=nil;
  FPageHeader:=nil;
  FPageFooter:=nil;
  FPrintGridLines:=nil;
  FLeftMargin:=nil; FRightMargin:=nil; FTopMargin:=nil; FBottomMargin:=nil;
  FSetup:=nil;
  FPrinterDriverSettings:=nil;
  FWSBool:=nil;
  FZoom:=nil;
  FGuts:=nil;
  FRefMode:=nil;
  FPane:=nil;

  //don't FPrintRecords:=nil;
  //don't FCodeName:=nil;
end;

procedure TSheet.AddOrRemovePane(const Add: boolean);
begin

end;

{ TFlxChart }

procedure TFlxChart.ArrangeCopyRowsAndCols(const RowOffset, ColOffset: integer);
begin
  FChartRecords.ArrangeCopyRowsAndCols(RowOffset, ColOffset);
end;

procedure TFlxChart.ArrangeCopySheet(const SheetInfo: TSheetInfo);
begin
  FChartRecords.ArrangeCopySheet(SheetInfo);
end;

procedure TFlxChart.InsertAndCopyRowsAndCols(const FirstRow, LastRow, DestRow, aRowCount,FirstCol, LastCol, DestCol, aColCount: integer; const SheetInfo: TSheetInfo; const OnlyFormulas: boolean);
begin
  //Nothing, we never insert rows in a chart sheet
end;

procedure TFlxChart.DeleteRowsAndCols(const aRow, aRowCount, aCol, aColCount: word; const SheetInfo: TSheetInfo);
begin
  //Nothing, we never delete rows in a chart sheet
end;

procedure TFlxChart.Clear;
begin
  inherited;
  if FChartRecords<>nil then FChartRecords.Clear;
  //We don't clear CodeName.
end;

function TFlxChart.DoCopyTo: TSheet;
begin
  Result:= inherited DoCopyTo;
  (Result as TFlxChart).FChartRecords.CopyFrom(FChartRecords);
  (Result as TFlxChart).FPrintRecords:=(Result as TFlxChart).FChartRecords;
  Result.FixCachePointers;
end;

constructor TFlxChart.Create(const aWorkbookGlobals: TWorkbookGlobals);
begin
  inherited;
  FChartRecords:= TChartRecordList.Create;
  FPrintRecords:=FChartRecords;
end;

destructor TFlxChart.Destroy;
begin
  FreeAndNil(FChartRecords);
  FreeAndNil(FCodeName);
  inherited;
end;

procedure TFlxChart.LoadFromStream(const DataStream: TStream;
  const First: TBOFRecord; const SST: TSST);
var
  RecordHeader: TRecordHeader;
  R: TBaseRecord;
begin
  Clear;
  repeat
    if (DataStream.Read(RecordHeader, sizeof(RecordHeader)) <> sizeof(RecordHeader)) then
      raise Exception.Create(ErrExcelInvalid);

    R:=LoadRecord(DataStream, RecordHeader);
    try
      LoadCachePointers(R);

      if (R is TLabelSSTRecord) then (R as TLabelSSTRecord).AttachToSST(SST);
      if (R is TBofRecord) then raise Exception.Create(ErrExcelInvalid)
      else if (R is TIgnoreRecord) then FreeAndNil(R)
      else if (R is TDimensionsRecord) then begin; OriginalDimensions:=(R as TDimensionsRecord).Dim^; FreeAndNil(R);end
      else if (R is TEOFRecord) then sEOF:=(R as TEOFRecord)
      else if (R is TCodeNameRecord) then begin; FreeAndNil(FCodeName); FCodeName:=(R as TCodeNameRecord); end
      else FChartRecords.Add(R) ;
    except
      FreeAndNil(R);
      Raise;
    end; //Finally

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -