From 95ddacdc6a0c6d97e3d90882db20a14c52090c51 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 11 Dec 2012 16:53:54 +0000 Subject: [PATCH] fpspreadsheet: Patch from bug 22398 which improves the biff2 reader git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2600 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/xlsbiff2.pas | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/components/fpspreadsheet/xlsbiff2.pas b/components/fpspreadsheet/xlsbiff2.pas index b2668276f..0ec03daff 100755 --- a/components/fpspreadsheet/xlsbiff2.pas +++ b/components/fpspreadsheet/xlsbiff2.pas @@ -51,6 +51,7 @@ type procedure ReadFormula(AStream: TStream); override; procedure ReadLabel(AStream: TStream); override; procedure ReadNumber(AStream: TStream); override; + procedure ReadInteger(AStream: TStream); end; { TsSpreadBIFF2Writer } @@ -74,6 +75,7 @@ implementation const { Excel record IDs } + INT_EXCEL_ID_INTEGER = $0002; INT_EXCEL_ID_NUMBER = $0003; INT_EXCEL_ID_LABEL = $0004; INT_EXCEL_ID_FORMULA = $0006; @@ -392,11 +394,13 @@ begin case RecordType of + INT_EXCEL_ID_INTEGER: ReadInteger(AStream); INT_EXCEL_ID_NUMBER: ReadNumber(AStream); INT_EXCEL_ID_LABEL: ReadLabel(AStream); INT_EXCEL_ID_FORMULA: ReadFormula(AStream); INT_EXCEL_ID_BOF: ; INT_EXCEL_ID_EOF: BIFF2EOF := True; + else // nothing end; @@ -460,6 +464,27 @@ begin FWorksheet.WriteNumber(ARow, ACol, AValue); end; +procedure TsSpreadBIFF2Reader.ReadInteger(AStream: TStream); +var + ARow, ACol: Word; + AWord : Word; +begin + { BIFF Record data } + ARow := WordLEToN(AStream.ReadWord); + ACol := WordLEToN(AStream.ReadWord); + + { BIFF2 Attributes } + AStream.ReadByte(); + AStream.ReadByte(); + AStream.ReadByte(); + + { 16 bit unsigned integer } + AStream.ReadBuffer(AWord, 2); + + { Save the data } + FWorksheet.WriteNumber(ARow, ACol, AWord); +end; + {******************************************************************* * Initialization section * @@ -472,4 +497,3 @@ initialization RegisterSpreadFormat(TsSpreadBIFF2Reader, TsSpreadBIFF2Writer, sfExcel2); end. -