📄 sheetdata2.pas
字号:
//:# List with conditional formats.
property ConditionalFormats: TConditionalFormats read FConditionalFormats write FConditionalFormats;
end;
//:# List with TSheet objects.
TSheets = class(TCollection)
private
FSST: TSST2;
FXLSMask: TExcelMask;
function GetSheet(Index: integer): TSheet;
protected
FOwner: TPersistent;
function GetOwner: TPersistent; override;
procedure SetBufSize(Value: integer);
function GetBufSize: integer;
public
constructor Create(AOwner: TPersistent);
destructor Destroy; override;
//:# Delete the sheet at Index.
procedure Delete(Index: integer);
//:# Deletes all sheets.
//: When deleting all sheets, a new, empty sheet is added automatically,
//: as there has to be at least one sheet.
procedure Clear;
//:# Add a new sheet.
function Add: TSheet;
//:# Returns a sheet by it's name. If the name not is found, Nil is returned.
function SheetByName(Name: WideString): TSheet;
// **********************************************
// *********** For internal use only. ***********
// **********************************************
//: @exclude
procedure WriteSST(Stream: TXLSStream);
//: @exclude
procedure ReadSST(Stream: TXLSStream; RecSize: word);
//: @exclude
procedure ClearAll;
property MaxBufSize: integer read GetBufSize write SetBufSize;
property SST: TSST2 read FSST;
// **********************************************
// *********** End internal use only. ***********
// **********************************************
//:# The sheets in the list.
property Items[Index: integer]: TSheet read GetSheet; default;
{$ifdef OLD_COMPILER}
property Owner: TPersistent read FOwner;
{$endif}
end;
implementation
uses XLSReadWriteII2, CalculateFormula2;
{ TPrintSettings }
constructor TPrintSettings.Create(Parent: TSheet);
begin
FParent := Parent;
StartingPage := 1;
Options := [psoPortrait];
MarginLeft := -1;
MarginRight := -1;
MarginTop := -1;
MarginBottom := -1;
FHorizPagebreaks := THorizPagebreaks.Create(Self);
FVertPagebreaks := TVertPagebreaks.Create(Self);
end;
procedure TPrintSettings.Clear;
begin
StartingPage := 1;
Options := [psoPortrait];
MarginLeft := -1;
MarginRight := -1;
MarginTop := -1;
MarginBottom := -1;
FHorizPagebreaks.Clear;
FVertPagebreaks.Clear;
end;
destructor TPrintSettings.Destroy;
begin
FHorizPagebreaks.Free;
FVertPagebreaks.Free;
inherited;
end;
function TPrintSettings.GetOwner: TPersistent;
begin
Result := FParent;
end;
// psoLeftToRight,psoPortrait,psoNoColor,psoDraftQuality,psoNotes,,,,
function TPrintSettings.GetOptions: TPrintSetupOptions;
begin
Result := [];
if FParent.Records.PRINTHEADERS then
Result := Result + [psoRowColHeading];
if FParent.Records.PRINTGRIDLINES then
Result := Result + [psoGridlines];
if FParent.Records.HCENTER then
Result := Result + [psoHorizCenter];
if FParent.Records.VCENTER then
Result := Result + [psoVertCenter];
if (FParent.Records.SETUP.Options and $0001) = $0001 then
Result := Result + [psoLeftToRight];
if (FParent.Records.SETUP.Options and $0002) = $0002 then
Result := Result + [psoPortrait];
if (FParent.Records.SETUP.Options and $0008) = $0008 then
Result := Result + [psoNoColor];
if (FParent.Records.SETUP.Options and $0010) = $0010 then
Result := Result + [psoDraftQuality];
if (FParent.Records.SETUP.Options and $0020) = $0020 then
Result := Result + [psoNotes];
end;
procedure TPrintSettings.SetOptions(const Value: TPrintSetupOptions);
begin
FParent.Records.PRINTHEADERS := psoRowColHeading in Value;
FParent.Records.PRINTGRIDLINES := psoGridlines in Value;
FParent.Records.HCENTER := psoHorizCenter in Value;
FParent.Records.VCENTER := psoVertCenter in Value;
FParent.Records.SETUP.Options := $0000;
if psoLeftToRight in Value then
FParent.Records.SETUP.Options := FParent.Records.SETUP.Options + $0001;
if psoPortrait in Value then
FParent.Records.SETUP.Options := FParent.Records.SETUP.Options + $0002;
if psoNoColor in Value then
FParent.Records.SETUP.Options := FParent.Records.SETUP.Options + $0008;
if psoDraftQuality in Value then
FParent.Records.SETUP.Options := FParent.Records.SETUP.Options + $0010;
if psoNotes in Value then
FParent.Records.SETUP.Options := FParent.Records.SETUP.Options + $0020;
end;
function TPrintSettings.GetCopies: word;
begin
Result := FParent.Records.SETUP.Copies;
end;
function TPrintSettings.GetFooterMargin: double;
begin
Result := FParent.Records.SETUP.FooterMargin;
end;
function TPrintSettings.GetHeaderMargin: double;
begin
Result := FParent.Records.SETUP.HeaderMargin;
end;
function TPrintSettings.GetPaperSize: TPaperSize;
begin
Result := TPaperSize(FParent.Records.SETUP.PaperSize);
end;
function TPrintSettings.GetScalingFactor: word;
begin
Result := FParent.Records.SETUP.Scale;
end;
function TPrintSettings.GetStartingPage: word;
begin
Result := FParent.Records.SETUP.PageStart;
end;
procedure TPrintSettings.SetCopies(const Value: word);
begin
FParent.Records.SETUP.Copies := Value;
end;
procedure TPrintSettings.SetFooterMargin(const Value: double);
begin
FParent.Records.SETUP.FooterMargin := Value;
end;
procedure TPrintSettings.SetHeaderMargin(const Value: double);
begin
FParent.Records.SETUP.HeaderMargin := Value;
end;
procedure TPrintSettings.SetPaperSize(const Value: TPaperSize);
begin
FParent.Records.SETUP.PaperSize := Word(Value);
end;
procedure TPrintSettings.SetScalingFactor(const Value: word);
begin
FParent.Records.SETUP.Scale := Value;
end;
procedure TPrintSettings.SetStartingPage(const Value: word);
begin
FParent.Records.SETUP.PageStart := Value;
end;
function TPrintSettings.GetResolution: integer;
begin
Result := FParent.Records.SETUP.Resolution;
end;
procedure TPrintSettings.SetResolution(const Value: integer);
begin
FParent.Records.SETUP.Resolution := Value;
end;
function TPrintSettings.GetMarginBottomCm: double;
begin
Result := FMarginBottom * 2.54;
end;
function TPrintSettings.GetMarginLeftCm: double;
begin
Result := FMarginLeft * 2.54;
end;
function TPrintSettings.GetMarginRightCm: double;
begin
Result := FMarginRight * 2.54;
end;
function TPrintSettings.GetMarginTopCm: double;
begin
Result := FMarginTop * 2.54;
end;
procedure TPrintSettings.SetMarginBottomCm(const Value: double);
begin
FMarginBottom := Value / 2.54;
end;
procedure TPrintSettings.SetMarginLeftCm(const Value: double);
begin
FMarginLeft := Value / 2.54;
end;
procedure TPrintSettings.SetMarginRightCm(const Value: double);
begin
FMarginRight := Value / 2.54;
end;
procedure TPrintSettings.SetMarginTopCm(const Value: double);
begin
FMarginTop := Value / 2.54;
end;
{ TSheets }
constructor TSheets.Create(AOwner: TPersistent);
begin
inherited Create(TSheet);
FOwner := AOwner;
FSST := TSST2.Create(TXLSReadWriteII2(FOwner).Fonts);
FXLSMask := TExcelMask.Create;
end;
destructor TSheets.Destroy;
begin
FSST.Free;
FXLSMask.Free;
inherited;
end;
procedure TSheets.Delete(Index: integer);
begin
{$ifndef ver120}
inherited Delete(Index);
{$endif}
if Count < 1 then
Add;
end;
procedure TSheets.ClearAll;
var
i: integer;
begin
FSST.Clear;
for i := 0 to Count - 1 do
Items[i].ClearData;
inherited Clear;
end;
procedure TSheets.Clear;
begin
ClearAll;
Add;
end;
function TSheets.GetSheet(Index: integer): TSheet;
begin
Result := TSheet(inherited Items[Index]);
end;
procedure TSheets.SetBufSize(Value: integer);
begin
FSST.MaxBufSize := Value;
end;
function TSheets.GetBufSize: integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -