From ca0980e0ed88a20069200a4b9de186c200434a3e Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 11 Dec 2012 16:46:25 +0000 Subject: [PATCH] fpspreadsheet: Patch from bug 21400, adds date reading support to the ods reader git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2599 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpsopendocument.pas | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas index 9bf4df894..ab6b0cb7b 100755 --- a/components/fpspreadsheet/fpsopendocument.pas +++ b/components/fpspreadsheet/fpsopendocument.pas @@ -49,6 +49,7 @@ type procedure ReadFormula(ARow : Word; ACol : Word; ACellNode: TDOMNode); procedure ReadLabel(ARow : Word; ACol : Word; ACellNode: TDOMNode); procedure ReadNumber(ARow : Word; ACol : Word; ACellNode: TDOMNode); + procedure ReadDate(ARow : Word; ACol : Word; ACellNode: TDOMNode); end; { TsSpreadOpenDocWriter } @@ -214,7 +215,9 @@ begin else if ParamFormula<>'' then ReadFormula(Row+RowsCount,Col+ColsCount,CellNode) else if ParamValueType='float' then - ReadNumber(Row+RowsCount,Col+ColsCount,CellNode); + ReadNumber(Row+RowsCount,Col+ColsCount,CellNode) + else if ParamValueType='date' then + ReadDate(Row+RowsCount,Col+ColsCount,CellNode); end; //for ColsCount end; //for RowsCount @@ -265,6 +268,16 @@ begin end; end; +procedure TsSpreadOpenDocReader.ReadDate(ARow: Word; ACol : Word; ACellNode : TDOMNode); +var + Value: String; + dt:TDateTime; +begin + Value:=GetAttrValue(ACellNode,'office:date-value'); + dt:=StrToDate(Value,'yyyy-mm-dd','-'); + FWorkSheet.WriteDateTime(Arow,ACol,dt); +end; + { TsSpreadOpenDocWriter } procedure TsSpreadOpenDocWriter.WriteMimetype;