2015-01-23 21:54:23 +00:00
|
|
|
unit fpsCell;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
{$modeswitch advancedrecords}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, fpstypes, fpspreadsheet;
|
|
|
|
|
|
|
|
type
|
|
|
|
TCellHelper = record helper for TCell
|
|
|
|
private
|
|
|
|
function GetBackgroundColor: TsColor;
|
|
|
|
function GetBorder: TsCellBorders;
|
2015-01-24 00:36:10 +00:00
|
|
|
function GetBorderStyle(const ABorder: TsCellBorder): TsCellBorderStyle;
|
2015-01-25 23:30:15 +00:00
|
|
|
function GetBorderStyles: TsCellBorderStyles;
|
2015-01-23 21:54:23 +00:00
|
|
|
function GetCellFormat: TsCellFormat;
|
2015-02-15 22:18:38 +00:00
|
|
|
function GetComment: String;
|
2015-01-23 21:54:23 +00:00
|
|
|
function GetFont: TsFont;
|
|
|
|
function GetFontIndex: integer;
|
|
|
|
function GetHorAlignment: TsHorAlignment;
|
2015-02-22 23:38:28 +00:00
|
|
|
function GetHyperlink: TsHyperlink;
|
2015-01-23 21:54:23 +00:00
|
|
|
function GetNumberFormat: TsNumberFormat;
|
|
|
|
function GetNumberFormatStr: String;
|
|
|
|
function GetTextRotation: TsTextRotation;
|
2015-01-24 00:36:10 +00:00
|
|
|
function GetUsedFormattingFields: TsUsedFormattingFields;
|
2015-01-23 21:54:23 +00:00
|
|
|
function GetVertAlignment: TsVertAlignment;
|
|
|
|
function GetWordwrap: Boolean;
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure SetBackgroundColor(const AValue: TsColor);
|
|
|
|
procedure SetBorder(const AValue: TsCellBorders);
|
|
|
|
procedure SetBorderStyle(const ABorder: TsCellBorder; const AValue: TsCellBorderStyle);
|
2015-01-25 23:30:15 +00:00
|
|
|
procedure SetBorderStyles(const AValue: TsCellBorderStyles);
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure SetCellFormat(const AValue: TsCellFormat);
|
2015-02-15 22:18:38 +00:00
|
|
|
procedure SetComment(const AValue: String);
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure SetFontIndex(const AValue: Integer);
|
|
|
|
procedure SetHorAlignment(const AValue: TsHorAlignment);
|
2015-02-22 23:38:28 +00:00
|
|
|
procedure SetHyperlink(const AValue: TsHyperlink);
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure SetNumberFormat(const AValue: TsNumberFormat);
|
|
|
|
procedure SetNumberFormatStr(const AValue: String);
|
|
|
|
procedure SetTextRotation(const AValue: TsTextRotation);
|
|
|
|
procedure SetUsedFormattingFields(const AValue: TsUsedFormattingFields);
|
|
|
|
procedure SetVertAlignment(const AValue: TsVertAlignment);
|
|
|
|
procedure SetWordwrap(const AValue: Boolean);
|
2015-01-23 21:54:23 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
function GetWorkbook: TsWorkbook;
|
|
|
|
public
|
2015-01-24 00:36:10 +00:00
|
|
|
property BackgroundColor: TsColor
|
|
|
|
read GetBackgroundColor write SetBackgroundColor;
|
|
|
|
property Border: TsCellBorders
|
|
|
|
read GetBorder write SetBorder;
|
2015-01-25 23:30:15 +00:00
|
|
|
property BorderStyle[ABorder: TsCellBorder]: TsCellBorderStyle
|
|
|
|
read GetBorderStyle write SetBorderStyle;
|
|
|
|
property BorderStyles: TsCellBorderStyles
|
|
|
|
read GetBorderStyles write SetBorderStyles;
|
2015-01-24 00:36:10 +00:00
|
|
|
property CellFormat: TsCellFormat
|
|
|
|
read GetCellFormat write SetCellFormat;
|
2015-02-22 23:38:28 +00:00
|
|
|
property Comment: String
|
2015-02-24 00:30:26 +00:00
|
|
|
read GetComment write SetComment;
|
2015-01-23 21:54:23 +00:00
|
|
|
property Font: TsFont read GetFont;
|
2015-01-24 00:36:10 +00:00
|
|
|
property FontIndex: Integer
|
|
|
|
read GetFontIndex write SetFontIndex;
|
|
|
|
property HorAlignment: TsHorAlignment
|
|
|
|
read GetHorAlignment write SetHorAlignment;
|
2015-02-22 23:38:28 +00:00
|
|
|
property Hyperlink: TsHyperlink
|
|
|
|
read GetHyperlink write SetHyperlink;
|
2015-01-24 00:36:10 +00:00
|
|
|
property NumberFormat: TsNumberFormat
|
|
|
|
read GetNumberFormat write SetNumberFormat;
|
|
|
|
property NumberFormatStr: String
|
|
|
|
read GetNumberFormatStr write SetNumberFormatStr;
|
|
|
|
property TextRotation: TsTextRotation
|
|
|
|
read GetTextRotation write SetTextRotation;
|
|
|
|
property UsedFormattingFields: TsUsedFormattingFields
|
|
|
|
read GetUsedFormattingFields write SetUsedFormattingFields;
|
|
|
|
property VertAlignment: TsVertAlignment
|
|
|
|
read GetVertAlignment write SetVertAlignment;
|
|
|
|
property Wordwrap: Boolean
|
|
|
|
read GetWordwrap write SetWordwrap;
|
2015-01-23 21:54:23 +00:00
|
|
|
property Workbook: TsWorkbook read GetWorkbook;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
function TCellHelper.GetBackgroundColor: TsColor;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadBackgroundColor(@self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetBorder: TsCellBorders;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadCellBorders(@self);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
function TCellHelper.GetBorderStyle(const ABorder: TsCellBorder): TsCellBorderStyle;
|
2015-01-23 21:54:23 +00:00
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadCellBorderStyle(@self, ABorder);
|
|
|
|
end;
|
|
|
|
|
2015-01-25 23:30:15 +00:00
|
|
|
function TCellHelper.GetBorderStyles: TsCellBorderStyles;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadCellBorderStyles(@self);
|
|
|
|
end;
|
|
|
|
|
2015-01-23 21:54:23 +00:00
|
|
|
function TCellHelper.GetCellFormat: TsCellFormat;
|
|
|
|
begin
|
|
|
|
Result := Workbook.GetCellFormat(FormatIndex);
|
|
|
|
end;
|
|
|
|
|
2015-02-15 22:18:38 +00:00
|
|
|
function TCellHelper.GetComment: String;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadComment(@self);
|
|
|
|
end;
|
|
|
|
|
2015-01-23 21:54:23 +00:00
|
|
|
function TCellHelper.GetFont: TsFont;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadCellFont(@self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetFontIndex: Integer;
|
|
|
|
var
|
|
|
|
fmt: PsCellFormat;
|
|
|
|
begin
|
|
|
|
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
|
|
|
|
Result := fmt^.FontIndex;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetHorAlignment: TsHorAlignment;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadHorAlignment(@Self);
|
|
|
|
end;
|
|
|
|
|
2015-02-22 23:38:28 +00:00
|
|
|
function TCellHelper.GetHyperlink: TsHyperlink;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadHyperlink(@self);
|
|
|
|
end;
|
|
|
|
|
2015-01-23 21:54:23 +00:00
|
|
|
function TCellHelper.GetNumberFormat: TsNumberFormat;
|
|
|
|
var
|
|
|
|
fmt: PsCellFormat;
|
|
|
|
begin
|
|
|
|
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
|
|
|
|
Result := fmt^.NumberFormat;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetNumberFormatStr: String;
|
|
|
|
var
|
|
|
|
fmt: PsCellFormat;
|
|
|
|
begin
|
|
|
|
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
|
|
|
|
Result := fmt^.NumberFormatStr;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetTextRotation: TsTextRotation;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadTextRotation(@Self);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
function TCellHelper.GetUsedFormattingFields: TsUsedFormattingFields;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadUsedFormatting(@Self);
|
|
|
|
end;
|
|
|
|
|
2015-01-23 21:54:23 +00:00
|
|
|
function TCellHelper.GetVertAlignment: TsVertAlignment;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadVertAlignment(@self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetWordwrap: Boolean;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.ReadWordwrap(@self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCellHelper.GetWorkbook: TsWorkbook;
|
|
|
|
begin
|
|
|
|
Result := Worksheet.Workbook;
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetBackgroundColor(const AValue: TsColor);
|
2015-01-23 21:54:23 +00:00
|
|
|
begin
|
|
|
|
Worksheet.WriteBackgroundColor(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetBorder(const AValue: TsCellBorders);
|
2015-01-23 21:54:23 +00:00
|
|
|
begin
|
|
|
|
Worksheet.WriteBorders(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetBorderStyle(const ABorder: TsCellBorder;
|
|
|
|
const AValue: TsCellBorderStyle);
|
2015-01-23 21:54:23 +00:00
|
|
|
begin
|
|
|
|
Worksheet.WriteBorderStyle(@self, ABorder, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-25 23:30:15 +00:00
|
|
|
procedure TCellHelper.SetBorderStyles(const AValue: TsCellBorderStyles);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteBorderStyles(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetCellFormat(const AValue: TsCellFormat);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteCellFormat(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-02-15 22:18:38 +00:00
|
|
|
procedure TCellHelper.SetComment(const AValue: String);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteComment(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetFontIndex(const AValue: Integer);
|
2015-01-23 21:54:23 +00:00
|
|
|
begin
|
|
|
|
Worksheet.WriteFont(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetHorAlignment(const AValue: TsHorAlignment);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteHorAlignment(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
2015-02-22 23:38:28 +00:00
|
|
|
procedure TCellHelper.SetHyperlink(const AValue: TsHyperlink);
|
|
|
|
begin
|
2015-02-28 23:46:08 +00:00
|
|
|
Worksheet.WriteHyperlink(@self, AValue.Target, AValue.Tooltip);
|
2015-02-22 23:38:28 +00:00
|
|
|
end;
|
|
|
|
|
2015-01-24 00:36:10 +00:00
|
|
|
procedure TCellHelper.SetNumberFormat(const AValue: TsNumberFormat);
|
|
|
|
var
|
|
|
|
fmt: TsCellFormat;
|
|
|
|
begin
|
|
|
|
fmt := Workbook.GetCellFormat(FormatIndex);
|
|
|
|
fmt.NumberFormat := AValue;
|
|
|
|
Worksheet.WriteCellFormat(@self, fmt);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCellHelper.SetNumberFormatStr(const AValue: String);
|
|
|
|
var
|
|
|
|
fmt: TsCellFormat;
|
|
|
|
begin
|
|
|
|
fmt := Workbook.GetCellFormat(FormatIndex);
|
|
|
|
fmt.NumberFormatStr := AValue;
|
|
|
|
Worksheet.WriteCellFormat(@self, fmt);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCellHelper.SetTextRotation(const AValue: TsTextRotation);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteTextRotation(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCellHelper.SetUsedFormattingFields(const AValue: TsUsedFormattingFields);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteUsedFormatting(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCellHelper.SetVertAlignment(const AValue: TsVertAlignment);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteVertAlignment(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCellHelper.SetWordwrap(const AValue: Boolean);
|
|
|
|
begin
|
|
|
|
Worksheet.WriteWordwrap(@self, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2015-01-23 21:54:23 +00:00
|
|
|
end.
|
|
|
|
|