You've already forked lazarus-ccr
fpspreadsheet: Split cell format code off into separate include file.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7545 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -34,252 +34,256 @@
|
||||
This package is all you need if you don't want graphical components (like grids and charts)."/>
|
||||
<License Value="LGPL with static linking exception. This is the same license as is used in the LCL (Lazarus Component Library)."/>
|
||||
<Version Major="1" Minor="13"/>
|
||||
<Files Count="48">
|
||||
<Item1>
|
||||
<Files>
|
||||
<Item>
|
||||
<Filename Value="source\fps.inc"/>
|
||||
<Type Value="Include"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpolebasic.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpolebasic"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpolestorage.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpolestorage"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsallformats.pas"/>
|
||||
<UnitName Value="fpsallformats"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpscell.pas"/>
|
||||
<UnitName Value="fpsCell"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsclasses.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsclasses"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpscsv.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpscsv"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpscsvdocument.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsCsvDocument"/>
|
||||
</Item8>
|
||||
<Item9>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpscurrency.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsCurrency"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsexprparser.pas"/>
|
||||
<UnitName Value="fpsExprParser"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsfunc.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsfunc"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsheaderfooterparser.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsHeaderFooterParser"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpshtml.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsHTML"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpshtmlutils.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsHTMLUtils"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsimages.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsImages"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsnumformat.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsNumFormat"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsopendocument.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsopendocument"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspagelayout.pas"/>
|
||||
<UnitName Value="fpsPageLayout"/>
|
||||
</Item18>
|
||||
<Item19>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspalette.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsPalette"/>
|
||||
</Item19>
|
||||
<Item20>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspatches.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpspatches"/>
|
||||
</Item20>
|
||||
<Item21>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspreadsheet.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpspreadsheet"/>
|
||||
</Item21>
|
||||
<Item22>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsreaderwriter.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsReaderWriter"/>
|
||||
</Item22>
|
||||
<Item23>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsrpn.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsRPN"/>
|
||||
</Item23>
|
||||
<Item24>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsstreams.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsStreams"/>
|
||||
</Item24>
|
||||
<Item25>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsstrings.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsStrings"/>
|
||||
</Item25>
|
||||
<Item26>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpstypes.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsTypes"/>
|
||||
</Item26>
|
||||
<Item27>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsutils.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsutils"/>
|
||||
</Item27>
|
||||
<Item28>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsxmlcommon.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpsxmlcommon"/>
|
||||
</Item28>
|
||||
<Item29>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpszipper.pp"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="fpszipper"/>
|
||||
</Item29>
|
||||
<Item30>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer"/>
|
||||
</Item30>
|
||||
<Item31>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer_ole.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer_ole"/>
|
||||
</Item31>
|
||||
<Item32>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer_ole_helpers.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer_ole_helpers"/>
|
||||
</Item32>
|
||||
<Item33>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer_ole_types.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer_ole_types"/>
|
||||
</Item33>
|
||||
<Item34>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer_stream.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer_stream"/>
|
||||
</Item34>
|
||||
<Item35>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\uvirtuallayer_types.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="uvirtuallayer_types"/>
|
||||
</Item35>
|
||||
<Item36>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\wikitable.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="wikitable"/>
|
||||
</Item36>
|
||||
<Item37>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsbiff2.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsbiff2"/>
|
||||
</Item37>
|
||||
<Item38>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsbiff5.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsbiff5"/>
|
||||
</Item38>
|
||||
<Item39>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsbiff8.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsbiff8"/>
|
||||
</Item39>
|
||||
<Item40>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlscommon.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlscommon"/>
|
||||
</Item40>
|
||||
<Item41>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsconst.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsconst"/>
|
||||
</Item41>
|
||||
<Item42>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsescher.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsEscher"/>
|
||||
</Item42>
|
||||
<Item43>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsxml.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsxml"/>
|
||||
</Item43>
|
||||
<Item44>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\xlsxooxml.pas"/>
|
||||
<AddToUsesPkgSection Value="False"/>
|
||||
<UnitName Value="xlsxooxml"/>
|
||||
</Item44>
|
||||
<Item45>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpssearch.pas"/>
|
||||
<UnitName Value="fpsSearch"/>
|
||||
</Item45>
|
||||
<Item46>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpscrypto.pas"/>
|
||||
<UnitName Value="fpsCrypto"/>
|
||||
</Item46>
|
||||
<Item47>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpsconditionalformat.pas"/>
|
||||
<UnitName Value="fpsConditionalFormat"/>
|
||||
</Item47>
|
||||
<Item48>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspreadsheet_cf.inc"/>
|
||||
<Type Value="Binary"/>
|
||||
</Item48>
|
||||
</Item>
|
||||
<Item>
|
||||
<Filename Value="source\common\fpspreadsheet_fmt.inc"/>
|
||||
<Type Value="Binary"/>
|
||||
</Item>
|
||||
</Files>
|
||||
<i18n>
|
||||
<EnableI18N Value="True"/>
|
||||
<OutDir Value="languages"/>
|
||||
<EnableI18NForLFM Value="True"/>
|
||||
</i18n>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
<RequiredPkgs>
|
||||
<Item>
|
||||
<PackageName Value="LazUtils"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item2>
|
||||
</Item>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
|
File diff suppressed because it is too large
Load Diff
929
components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc
Normal file
929
components/fpspreadsheet/source/common/fpspreadsheet_fmt.inc
Normal file
@ -0,0 +1,929 @@
|
||||
{ Included by fpspreadsheet.pas }
|
||||
{ Contains code for cell formatting }
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Modifies the background parameters of the format record stored at the
|
||||
specified index.
|
||||
|
||||
@param AFormatIndex Index of the format record to be changed
|
||||
@param AStyle Fill style ("pattern") to be used - see TsFillStyle
|
||||
@param APatternColor RGB value of the pattern color
|
||||
@param ABackgroundColor RGB value of the background color
|
||||
|
||||
@return Index of the new format record.
|
||||
|
||||
@NOTE When AStyle is fsSolidFill the color is defined by APatternColor,
|
||||
ABackgroundColor is ignored unless the APatternColor is not
|
||||
used (scTransparent).
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.ChangeBackground(AFormatIndex: Integer; AStyle: TsFillStyle;
|
||||
APatternColor: TsColor = scTransparent;
|
||||
ABackgroundColor: TsColor = scTransparent): Integer;
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
fmt := Workbook.GetCellFormat(AFormatIndex);
|
||||
if (AStyle = fsNoFill) or
|
||||
((APatternColor = scTransparent) and (ABackgroundColor = scTransparent))
|
||||
then
|
||||
Exclude(fmt.UsedFormattingFields, uffBackground)
|
||||
else
|
||||
begin
|
||||
Include(fmt.UsedFormattingFields, uffBackground);
|
||||
fmt.Background.Style := AStyle;
|
||||
fmt.Background.FgColor := APatternColor;
|
||||
if (AStyle = fsSolidFill) and (APatternColor = scTransparent) then
|
||||
fmt.Background.FgColor := ABackgroundColor
|
||||
else
|
||||
fmt.Background.BgColor := ABackgroundColor;
|
||||
end;
|
||||
Result := Workbook.AddCellFormat(fmt);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines a background pattern for a cell
|
||||
|
||||
@param ARow Row index of the cell
|
||||
@param ACol Column index of the cell
|
||||
@param AFillStyle Fill style to be used - see TsFillStyle
|
||||
@param APatternColor RGB value of the pattern color
|
||||
@param ABackgroundColor RGB value of the background color
|
||||
@return Pointer to cell
|
||||
|
||||
@NOTE When AStyle is fsSolidFill the color is defined by APatternColor,
|
||||
ABackgroundColor is ignored unless the APatternColor is not
|
||||
used (scTransparent).
|
||||
|
||||
@NOTE Is replaced by uniform fill if WriteBackgroundColor is called later.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBackground(ARow, ACol: Cardinal; AStyle: TsFillStyle;
|
||||
APatternColor, ABackgroundColor: TsColor): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBackground(Result, AStyle, APatternColor, ABackgroundColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines a background pattern for a cell
|
||||
|
||||
@param ACell Pointer to the cell
|
||||
@param AStyle Fill style ("pattern") to be used - see TsFillStyle
|
||||
@param APatternColor RGB value of the pattern color
|
||||
@param ABackgroundColor RGB value of the background color
|
||||
|
||||
@NOTE When AStyle is fsSolidFill the color is defined by APatternColor,
|
||||
ABackgroundColor is ignored unless the APatternColor is not
|
||||
used (scTransparent).
|
||||
|
||||
@NOTE Is replaced by uniform fill if WriteBackgroundColor is called later.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBackground(ACell: PCell; AStyle: TsFillStyle;
|
||||
APatternColor: TsColor = scTransparent; ABackgroundColor: TsColor = scTransparent);
|
||||
var
|
||||
idx: Integer;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
idx := ACell^.FormatIndex;
|
||||
ACell^.FormatIndex := ChangeBackground(idx, AStyle, APatternColor, ABackgroundColor);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets a uniform background color of a cell.
|
||||
|
||||
@param ARow Row index of the cell
|
||||
@param ACol Column index of the cell
|
||||
@param AColor RGB value of the new background color.
|
||||
Use the value "scTransparent" to clear an existing
|
||||
background color.
|
||||
@return Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBackgroundColor(ARow, ACol: Cardinal;
|
||||
AColor: TsColor): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBackgroundColor(Result, AColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets a uniform background color of a cell.
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param AColor RGB value of the new background color.
|
||||
Use the value "scTransparent" to clear an existing
|
||||
background color.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBackgroundColor(ACell: PCell; AColor: TsColor);
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
if AColor = scTransparent then
|
||||
WriteBackground(ACell, fsNoFill)
|
||||
else
|
||||
WriteBackground(ACell, fsSolidFill, AColor, AColor);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsWorksheet.WriteBiDiMode(ARow, ACol: Cardinal; AValue: TsBiDiMode): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBiDiMode(Result, AValue);
|
||||
end;
|
||||
|
||||
procedure TsWorksheet.WriteBiDiMode(ACell: PCell; AValue: TsBiDiMode);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.BiDiMode := AValue;
|
||||
if AValue <> bdDefault then
|
||||
Include(fmt.UsedFormattingFields, uffBiDi)
|
||||
else
|
||||
Exclude(fmt.UsedFormattingFields, uffBiDi);
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the color of a cell border line.
|
||||
Note: the border must be included in Borders set in order to be shown!
|
||||
|
||||
@param ARow Row index of the cell
|
||||
@param ACol Column index of the cell
|
||||
@param ABorder Indicates to which border (left/top etc) this color is
|
||||
to be applied
|
||||
@param AColor RGB value of the new border color
|
||||
@return Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorderColor(ARow, ACol: Cardinal;
|
||||
ABorder: TsCellBorder; AColor: TsColor): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorderColor(Result, ABorder, AColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the color of a cell border line.
|
||||
Note: the border must be included in Borders set in order to be shown!
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ABorder Indicates to which border (left/top etc) this color is
|
||||
to be applied
|
||||
@param AColor RGB value of the new border color
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorderColor(ACell: PCell; ABorder: TsCellBorder;
|
||||
AColor: TsColor);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.BorderStyles[ABorder].Color := AColor;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the linestyle of a cell border.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ARow Row index of the cell
|
||||
@param ACol Column index of the cell
|
||||
@param ABorder Indicates to which border (left/top etc) this color is
|
||||
to be applied
|
||||
@param ALineStyle Identifier of the new line style to be applied.
|
||||
@return Pointer to cell
|
||||
|
||||
@see TsLineStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorderLineStyle(ARow, ACol: Cardinal;
|
||||
ABorder: TsCellBorder; ALineStyle: TsLineStyle): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorderLineStyle(Result, ABorder, ALineStyle);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the linestyle of a cell border.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ABorder Indicates to which border (left/top etc) this color is
|
||||
to be applied
|
||||
@param ALineStyle Identifier of the new line style to be applied.
|
||||
|
||||
@see TsLineStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorderLineStyle(ACell: PCell;
|
||||
ABorder: TsCellBorder; ALineStyle: TsLineStyle);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.BorderStyles[ABorder].LineStyle := ALineStyle;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Shows the cell borders included in the set ABorders. No border lines are drawn
|
||||
for those not included.
|
||||
|
||||
The borders are drawn using the "BorderStyles" assigned to the cell.
|
||||
|
||||
@param ARow Row index of the cell
|
||||
@param ACol Column index of the cell
|
||||
@param ABorders Set with elements to identify the border(s) to will be shown
|
||||
@return Pointer to cell
|
||||
@see TsCellBorder
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorders(ARow, ACol: Cardinal; ABorders: TsCellBorders): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorders(Result, ABorders);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Shows the cell borders included in the set ABorders. No border lines are drawn
|
||||
for those not included.
|
||||
|
||||
The borders are drawn using the "BorderStyles" assigned to the cell.
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ABorders Set with elements to identify the border(s) to will be shown
|
||||
@see TsCellBorder
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorders(ACell: PCell; ABorders: TsCellBorders);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
if ABorders = [] then
|
||||
Exclude(fmt.UsedFormattingFields, uffBorder)
|
||||
else
|
||||
Include(fmt.UsedFormattingFields, uffBorder);
|
||||
fmt.Border := ABorders;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the style of a cell border, i.e. line style and line color.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ARow Row index of the cell considered
|
||||
@param ACol Column index of the cell considered
|
||||
@param ABorder Identifies the border to be modified (left/top/right/bottom)
|
||||
@param AStyle record of parameters controlling how the border line is drawn
|
||||
(line style, line color)
|
||||
@result Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorderStyle(ARow, ACol: Cardinal;
|
||||
ABorder: TsCellBorder; AStyle: TsCellBorderStyle): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorderStyle(Result, ABorder, AStyle);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the style of a cell border, i.e. line style and line color.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ABorder Identifies the border to be modified (left/top/right/bottom)
|
||||
@param AStyle record of parameters controlling how the border line is drawn
|
||||
(line style, line color)
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder;
|
||||
AStyle: TsCellBorderStyle);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.BorderStyles[ABorder] := AStyle;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets line style and line color of a cell border.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ARow Row index of the considered cell
|
||||
@param ACol Column index of the considered cell
|
||||
@param ABorder Identifier of the border to be modified
|
||||
@param ALineStyle Identifier for the new line style of the border
|
||||
@param AColor RGB value of the border line color
|
||||
@return Pointer to cell
|
||||
|
||||
@see WriteBorderStyles
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorderStyle(ARow, ACol: Cardinal;
|
||||
ABorder: TsCellBorder; ALineStyle: TsLineStyle; AColor: TsColor): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorderStyle(Result, ABorder, ALineStyle, AColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets line style and line color of a cell border.
|
||||
Note: the border must be included in the "Borders" set in order to be shown!
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ABorder Identifier of the border to be modified
|
||||
@param ALineStyle Identifier for the new line style of the border
|
||||
@param AColor RGB value of the color of the border line
|
||||
|
||||
@see WriteBorderStyles
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorderStyle(ACell: PCell; ABorder: TsCellBorder;
|
||||
ALineStyle: TsLineStyle; AColor: TsColor);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell <> nil then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.BorderStyles[ABorder].LineStyle := ALineStyle;
|
||||
fmt.BorderStyles[ABorder].Color := AColor;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the style of all cell border of a cell, i.e. line style and line color.
|
||||
Note: Only those borders included in the "Borders" set are shown!
|
||||
|
||||
@param ARow Row index of the considered cell
|
||||
@param ACol Column index of the considered cell
|
||||
@param AStyles Array of CellBorderStyles for each cell border.
|
||||
@return Pointer to cell
|
||||
|
||||
@see WriteBorderStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteBorderStyles(ARow, ACol: Cardinal;
|
||||
const AStyles: TsCellBorderStyles): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteBorderStyles(Result, AStyles);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Sets the style of all cell border of a cell, i.e. line style and line color.
|
||||
Note: Only those borders included in the "Borders" set are shown!
|
||||
|
||||
@param ACell Pointer to cell
|
||||
@param ACol Column index of the considered cell
|
||||
@param AStyles Array of CellBorderStyles for each cell border.
|
||||
|
||||
@see WriteBorderStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteBorderStyles(ACell: PCell;
|
||||
const AStyles: TsCellBorderStyles);
|
||||
var
|
||||
b: TsCellBorder;
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if Assigned(ACell) then begin
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
for b in TsCellBorder do fmt.BorderStyles[b] := AStyles[b];
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Assigns a complete cell format record to a cell
|
||||
|
||||
@param ACell Pointer to the cell to be modified
|
||||
@param ACellFormat Cell format record to be used by the cell
|
||||
|
||||
@see TsCellFormat
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteCellFormat(ACell: PCell;
|
||||
const ACellFormat: TsCellFormat);
|
||||
var
|
||||
idx: Integer;
|
||||
begin
|
||||
idx := Workbook.AddCellFormat(ACellFormat);
|
||||
WriteCellFormatIndex(ACell, idx);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Formats a cell to the cell format stored at the specified index in the
|
||||
workbook's cell format list.
|
||||
|
||||
@param ACell Pointer to the cell to be formatted
|
||||
@param AIndex Index of the cell format record to be used by the cell
|
||||
|
||||
@see TsCellFormat
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteCellFormatIndex(ACell: PCell; AIndex: Integer);
|
||||
begin
|
||||
if AIndex >= Workbook.GetNumCellFormats then
|
||||
raise EFpSpreadsheet.Create('[Worksheet.WriteCellFormat] Invalid cell format index.');
|
||||
|
||||
// The default format index is 0, but it could also be refered to by -1
|
||||
if AIndex < 0 then AIndex := 0;
|
||||
if Assigned(ACell) then begin
|
||||
ACell^.FormatIndex := AIndex;
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines how the cell at the specified row and column is protected: lock
|
||||
cell modification and/or hide formulas. Note that this is activated only after
|
||||
enabling worksheet protection (worksheet.Protect(true)).
|
||||
|
||||
NOTE:
|
||||
FPSpreadsheet does not enforce these actions. They are only written
|
||||
to the file for the Office application.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteCellProtection(ARow, ACol: Cardinal;
|
||||
AValue: TsCellProtections): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteCellProtection(Result, AValue);
|
||||
end;
|
||||
|
||||
procedure TsWorksheet.WriteCellProtection(ACell: PCell;
|
||||
AValue: TsCellProtections);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.Protection := AValue;
|
||||
if AValue <> DEFAULT_CELL_PROTECTION then
|
||||
Include(fmt.UsedFormattingFields, uffProtection)
|
||||
else
|
||||
Exclude(fmt.UsedFormattingFields, uffProtection);
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Adds font specification to the formatting of a cell. Looks in the workbook's
|
||||
FontList and creates an new entry if the font is not used so far. Returns the
|
||||
index of the font in the font list.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AFontName Name of the font
|
||||
@param AFontSize Size of the font, in points
|
||||
@param AFontStyle Set with font style attributes
|
||||
(don't use those of unit "graphics" !)
|
||||
@param AFontColor RGB value of the font's color
|
||||
@param APosition Specifies sub- or superscript text
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFont(ARow, ACol: Cardinal; const AFontName: String;
|
||||
AFontSize: Single; AFontStyle: TsFontStyles; AFontColor: TsColor;
|
||||
APosition: TsFontPosition = fpNormal): Integer;
|
||||
begin
|
||||
Result := WriteFont(GetCell(ARow, ACol), AFontName, AFontSize, AFontStyle,
|
||||
AFontColor, APosition);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Adds font specification to the formatting of a cell. Looks in the workbook's
|
||||
FontList and creates an new entry if the font is not used so far. Returns the
|
||||
index of the font in the font list.
|
||||
|
||||
@param ACell Pointer to the cell considered
|
||||
@param AFontName Name of the font
|
||||
@param AFontSize Size of the font, in points
|
||||
@param AFontStyle Set with font style attributes
|
||||
(don't use those of unit "graphics" !)
|
||||
@param AFontColor RGB value of the font's color
|
||||
@param APosition Specified subscript or superscript text.
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFont(ACell: PCell; const AFontName: String;
|
||||
AFontSize: Single; AFontStyle: TsFontStyles; AFontColor: TsColor;
|
||||
APosition: TsFontPosition = fpNormal): Integer;
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
begin
|
||||
Result := -1;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
Result := FWorkbook.FindFont(AFontName, AFontSize, AFontStyle, AFontColor, APosition);
|
||||
if Result = -1 then
|
||||
result := FWorkbook.AddFont(AFontName, AFontSize, AFontStyle, AFontColor, APosition);
|
||||
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
Include(fmt.UsedFormattingFields, uffFont);
|
||||
fmt.FontIndex := Result;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
|
||||
ChangedFont(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Applies a font to the formatting of a cell. The font is determined by its
|
||||
index in the workbook's font list:
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AFontIndex Index of the font in the workbook's font list
|
||||
@return Pointer to the cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFont(ARow, ACol: Cardinal; AFontIndex: Integer): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteFont(Result, AFontIndex);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Applies a font to the formatting of a cell. The font is determined by its
|
||||
index in the workbook's font list:
|
||||
|
||||
@param ACell Pointer to the cell considered
|
||||
@param AFontIndex Index of the font in the workbook's font list
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteFont(ACell: PCell; AFontIndex: Integer);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
|
||||
if (AFontIndex < 0) or (AFontIndex >= Workbook.GetFontCount) then
|
||||
raise EFPSpreadsheet.Create(rsInvalidFontIndex);
|
||||
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
Include(fmt.UsedFormattingFields, uffFont);
|
||||
fmt.FontIndex := AFontIndex;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
|
||||
ChangedFont(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the text color used in formatting of a cell. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AFontColor RGB value of the new text color
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontColor(ARow, ACol: Cardinal; AFontColor: TsColor): Integer;
|
||||
begin
|
||||
Result := WriteFontColor(GetCell(ARow, ACol), AFontColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the text color used in formatting of a cell. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ACell Pointer to the cell
|
||||
@param AFontColor RGB value of the new text color
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontColor(ACell: PCell; AFontColor: TsColor): Integer;
|
||||
var
|
||||
fnt: TsFont;
|
||||
begin
|
||||
if ACell = nil then begin
|
||||
Result := 0;
|
||||
exit;
|
||||
end;
|
||||
fnt := ReadCellFont(ACell);
|
||||
Result := WriteFont(ACell, fnt.FontName, fnt.Size, fnt.Style, AFontColor);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font used in formatting of a cell considering only the font face
|
||||
and leaving font size, style and color unchanged. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AFontName Name of the new font to be used
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontName(ARow, ACol: Cardinal; AFontName: String): Integer;
|
||||
begin
|
||||
result := WriteFontName(GetCell(ARow, ACol), AFontName);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font used in formatting of a cell considering only the font face
|
||||
and leaving font size, style and color unchanged. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ACell Pointer to the cell
|
||||
@param AFontName Name of the new font to be used
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontName(ACell: PCell; AFontName: String): Integer;
|
||||
var
|
||||
fnt: TsFont;
|
||||
begin
|
||||
if ACell = nil then begin
|
||||
Result := 0;
|
||||
exit;
|
||||
end;
|
||||
fnt := ReadCellFont(ACell);
|
||||
result := WriteFont(ACell, AFontName, fnt.Size, fnt.Style, fnt.Color);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font size in formatting of a cell. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param ASize Size of the font to be used (in points).
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontSize(ARow, ACol: Cardinal; ASize: Single): Integer;
|
||||
begin
|
||||
Result := WriteFontSize(GetCell(ARow, ACol), ASize);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font size in formatting of a cell. Looks in the workbook's
|
||||
font list if this modified font has already been used. If not a new font entry
|
||||
is created. Returns the index of this font in the font list.
|
||||
|
||||
@param ACell Pointer to the cell
|
||||
@param ASize Size of the font to be used (in points).
|
||||
@return Index of the font in the workbook's font list.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontSize(ACell: PCell; ASize: Single): Integer;
|
||||
var
|
||||
fnt: TsFont;
|
||||
begin
|
||||
if ACell = nil then begin
|
||||
Result := 0;
|
||||
exit;
|
||||
end;
|
||||
fnt := ReadCellFont(ACell);
|
||||
Result := WriteFont(ACell, fnt.FontName, ASize, fnt.Style, fnt.Color);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font style (bold, italic, etc) in formatting of a cell.
|
||||
Looks in the workbook's font list if this modified font has already been used.
|
||||
If not a new font entry is created.
|
||||
Returns the index of this font in the font list.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AStyle New font style to be used
|
||||
@return Index of the font in the workbook's font list.
|
||||
|
||||
@see TsFontStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontStyle(ARow, ACol: Cardinal;
|
||||
AStyle: TsFontStyles): Integer;
|
||||
begin
|
||||
Result := WriteFontStyle(GetCell(ARow, ACol), AStyle);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Replaces the font style (bold, italic, etc) in formatting of a cell.
|
||||
Looks in the workbook's font list if this modified font has already been used.
|
||||
If not a new font entry is created.
|
||||
Returns the index of this font in the font list.
|
||||
|
||||
@param ACell Pointer to the cell considered
|
||||
@param AStyle New font style to be used
|
||||
@return Index of the font in the workbook's font list.
|
||||
|
||||
@see TsFontStyle
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteFontStyle(ACell: PCell; AStyle: TsFontStyles): Integer;
|
||||
var
|
||||
fnt: TsFont;
|
||||
begin
|
||||
if ACell = nil then begin
|
||||
Result := -1;
|
||||
exit;
|
||||
end;
|
||||
fnt := ReadCellFont(ACell);
|
||||
Result := WriteFont(ACell, fnt.FontName, fnt.Size, AStyle, fnt.Color);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines the horizontal alignment of text in a cell.
|
||||
|
||||
@param ARow Row index of the cell considered
|
||||
@param ACol Column index of the cell considered
|
||||
@param AValue Parameter for horizontal text alignment
|
||||
(haDefault, vaLeft, haCenter, haRight)
|
||||
By default, texts are left-aligned, numbers and dates are
|
||||
right-aligned.
|
||||
@return Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteHorAlignment(ARow, ACol: Cardinal; AValue: TsHorAlignment): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteHorAlignment(Result, AValue);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines the horizontal alignment of text in a cell.
|
||||
|
||||
@param ACell Pointer to the cell considered
|
||||
@param AValue Parameter for horizontal text alignment
|
||||
(haDefault, vaLeft, haCenter, haRight)
|
||||
By default, texts are left-aligned, numbers and dates are
|
||||
right-aligned.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteHorAlignment(ACell: PCell; AValue: TsHorAlignment);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
if AValue = haDefault then
|
||||
Exclude(fmt.UsedFormattingFields, uffHorAlign)
|
||||
else
|
||||
Include(fmt.UsedFormattingFields, uffHorAlign);
|
||||
fmt.HorAlignment := AValue;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Adds text rotation to the formatting of a cell
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param ARotation How to rotate the text
|
||||
@return Pointer to cell
|
||||
|
||||
@see TsTextRotation
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteTextRotation(ARow, ACol: Cardinal;
|
||||
ARotation: TsTextRotation): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteTextRotation(Result, ARotation);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Adds text rotation to the formatting of a cell
|
||||
|
||||
@param ACell Pointer to the cell
|
||||
@param ARotation How to rotate the text
|
||||
|
||||
@see TsTextRotation
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteTextRotation(ACell: PCell; ARotation: TsTextRotation);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
Include(fmt.UsedFormattingFields, uffTextRotation);
|
||||
fmt.TextRotation := ARotation;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
|
||||
ChangedFont(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Directly modifies the used formatting fields of a cell.
|
||||
Only formatting corresponding to items included in this set is executed.
|
||||
|
||||
@param ARow The row of the cell
|
||||
@param ACol The column of the cell
|
||||
@param AUsedFormatting set of the used formatting fields
|
||||
@return Pointer to the (existing or created) cell
|
||||
|
||||
@see TsUsedFormattingFields
|
||||
@see TCell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteUsedFormatting(ARow, ACol: Cardinal;
|
||||
AUsedFormatting: TsUsedFormattingFields): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteUsedFormatting(Result, AUsedFormatting);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Directly modifies the used formatting fields of an existing cell.
|
||||
Only formatting corresponding to items included in this set is executed.
|
||||
|
||||
@param ACell Pointer to the cell to be modified
|
||||
@param AUsedFormatting set of the used formatting fields
|
||||
|
||||
@see TsUsedFormattingFields
|
||||
@see TCell
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteUsedFormatting(ACell: PCell;
|
||||
AUsedFormatting: TsUsedFormattingFields);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := FWorkbook.GetCellFormat(ACell^.FormatIndex);
|
||||
fmt.UsedFormattingFields := AUsedFormatting;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines the vertical alignment of text in a cell.
|
||||
|
||||
@param ARow Row index of the cell considered
|
||||
@param ACol Column index of the cell considered
|
||||
@param AValue Parameter for vertical text alignment
|
||||
(vaDefault, vaTop, vaCenter, vaBottom)
|
||||
By default, texts are bottom-aligned.
|
||||
@return Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteVertAlignment(ARow, ACol: Cardinal;
|
||||
AValue: TsVertAlignment): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteVertAlignment(Result, AValue);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Defines the vertical alignment of text in a cell.
|
||||
|
||||
@param ACell Poiner to the cell considered
|
||||
@param AValue Parameter for vertical text alignment
|
||||
(vaDefault, vaTop, vaCenter, vaBottom)
|
||||
By default, texts are bottom-aligned.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteVertAlignment(ACell: PCell; AValue: TsVertAlignment);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
if AValue = vaDefault then
|
||||
Exclude(fmt.UsedFormattingFields, uffVertAlign)
|
||||
else
|
||||
Include(fmt.UsedFormattingFields, uffVertAlign);
|
||||
fmt.VertAlignment := AValue;
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Enables or disables the word-wrapping feature for a cell.
|
||||
|
||||
@param ARow Row index of the cell considered
|
||||
@param ACol Column index of the cell considered
|
||||
@param AValue true = word-wrapping enabled, false = disabled.
|
||||
@return Pointer to cell
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorksheet.WriteWordwrap(ARow, ACol: Cardinal; AValue: boolean): PCell;
|
||||
begin
|
||||
Result := GetCell(ARow, ACol);
|
||||
WriteWordWrap(Result, AValue);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Enables or disables the word-wrapping feature for a cell.
|
||||
|
||||
@param ACel Pointer to the cell considered
|
||||
@param AValue true = word-wrapping enabled, false = disabled.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.WriteWordwrap(ACell: PCell; AValue: boolean);
|
||||
var
|
||||
fmt: TsCellFormat;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
fmt := Workbook.GetCellFormat(ACell^.FormatIndex);
|
||||
if AValue then
|
||||
Include(fmt.UsedFormattingFields, uffWordwrap)
|
||||
else
|
||||
Exclude(fmt.UsedFormattingFields, uffWordwrap);
|
||||
ACell^.FormatIndex := Workbook.AddCellFormat(fmt);
|
||||
ChangedCell(ACell^.Row, ACell^.Col);
|
||||
end;
|
||||
|
Reference in New Issue
Block a user