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

📄 tmsuxlssheet.pas

📁 TMS Component Pack V5.0包含了超过 280 个为 Delphi 以及 C++Builder 设计的 TMS 生产控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
end;

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

procedure TSheet.DeleteHPageBreak(const aRow: word);
begin
  //Nothing in TSheet
end;

procedure TSheet.DeleteVPageBreak(const aCol: word);
begin
  //Nothing in TSheet
end;

procedure TSheet.InsertHPageBreak(const aRow: word);
begin
  //Nothing in TSheet
end;

procedure TSheet.InsertVPageBreak(const aCol: word);
begin
  //Nothing in TSheet
end;

procedure TSheet.ArrangeCopySheet(const SheetInfo: TSheetInfo);
begin
  //Nothing in TSheet
end;

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

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: UTF16String;
begin
  if (FPageFooter<>nil) then Result:=FPageFooter.Text else Result:='';
end;

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

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

procedure TSheet.SetPageHeader(const Value: UTF16String);
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); //No dynamic fields like huge strings in Result.
  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(out 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(out xOffset: integer; out 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.FixRows;
begin

end;

function TSheet.FixTotalSize(const NeedsRecalc: boolean): int64;
begin
  Result := TotalSize;
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 else

  if R.Id=xlr_HCENTER then FHCenter := R as TPrintCenteredRecord else
  if R.Id=xlr_VCENTER then FVCenter := R as TPrintCenteredRecord;

  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;
  if R.Id=xlr_AUTOFILTERINFO then FAutoFilterInfo := R as TAutoFilterInfoRecord;

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: UTF16String;
begin
  if FCodeName<>nil then Result:=FCodeName.SheetName else Result:='';
end;

procedure TSheet.SetCodeName(const Value: UTF16String);
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;
  FHCenter := nil;
  FVCenter := nil;
  FZoom:=nil;
  FGuts:=nil;
  FRefMode:=nil;
  FPane:=nil;
  FAutoFilterInfo := nil;

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

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

end;

procedure TSheet.RestoreObjectCoords;
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;
  FreeAndNil(RemainingData);
  //We don't clear CodeName.

⌨️ 快捷键说明

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