From f34b79c6fd10720c5e7a7bf75b2170f10aec3b0e Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 15 Feb 2015 22:18:38 +0000 Subject: [PATCH] fpspreadsheet: Add TCell record helper to access cell comments from the cell git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3946 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpscell.pas | 12 ++++++++++++ components/fpspreadsheet/fpspreadsheet.pas | 9 +++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/fpspreadsheet/fpscell.pas b/components/fpspreadsheet/fpscell.pas index bc498e651..d741f3b88 100644 --- a/components/fpspreadsheet/fpscell.pas +++ b/components/fpspreadsheet/fpscell.pas @@ -16,6 +16,7 @@ type function GetBorderStyle(const ABorder: TsCellBorder): TsCellBorderStyle; function GetBorderStyles: TsCellBorderStyles; function GetCellFormat: TsCellFormat; + function GetComment: String; function GetFont: TsFont; function GetFontIndex: integer; function GetHorAlignment: TsHorAlignment; @@ -30,6 +31,7 @@ type procedure SetBorderStyle(const ABorder: TsCellBorder; const AValue: TsCellBorderStyle); procedure SetBorderStyles(const AValue: TsCellBorderStyles); procedure SetCellFormat(const AValue: TsCellFormat); + procedure SetComment(const AValue: String); procedure SetFontIndex(const AValue: Integer); procedure SetHorAlignment(const AValue: TsHorAlignment); procedure SetNumberFormat(const AValue: TsNumberFormat); @@ -99,6 +101,11 @@ begin Result := Workbook.GetCellFormat(FormatIndex); end; +function TCellHelper.GetComment: String; +begin + Result := Worksheet.ReadComment(@self); +end; + function TCellHelper.GetFont: TsFont; begin Result := Worksheet.ReadCellFont(@self); @@ -184,6 +191,11 @@ begin Worksheet.WriteCellFormat(@self, AValue); end; +procedure TCellHelper.SetComment(const AValue: String); +begin + Worksheet.WriteComment(@self, AValue); +end; + procedure TCellHelper.SetFontIndex(const AValue: Integer); begin Worksheet.WriteFont(@self, AValue); diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index e6829d7b7..9fe79b503 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -103,9 +103,9 @@ type PCol = ^TCol; {@@ The record TsComment contains a comment attached to a cell. - @param Row (0-based) index of the row containing the cell with the comment - @param Col (0-based) index of the column containing the coll with the comment - @param Text Comment text } + @param Row (0-based) index of the row with the cell + @param Col (0-based) index of the column with the cell + @param Text Comment text } TsComment = record Row, Col: Cardinal; Text: String; @@ -259,9 +259,6 @@ type function WriteCellValueAsString(ARow, ACol: Cardinal; AValue: String): PCell; overload; procedure WriteCellValueAsString(ACell: PCell; AValue: String); overload; -// function WriteComment(ARow, ACol: Cardinal; const AComment: String): PCell; overload; -// procedure WriteComment(ACell: PCell; const AComment: String); overload; - function WriteCurrency(ARow, ACol: Cardinal; AValue: Double; ANumFormat: TsNumberFormat = nfCurrency; ADecimals: Integer = 2; ACurrencySymbol: String = '?'; APosCurrFormat: Integer = -1;