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
This commit is contained in:
sekelsenmat
2012-12-11 16:53:54 +00:00
parent ca0980e0ed
commit 95ddacdc6a

View File

@ -51,6 +51,7 @@ type
procedure ReadFormula(AStream: TStream); override; procedure ReadFormula(AStream: TStream); override;
procedure ReadLabel(AStream: TStream); override; procedure ReadLabel(AStream: TStream); override;
procedure ReadNumber(AStream: TStream); override; procedure ReadNumber(AStream: TStream); override;
procedure ReadInteger(AStream: TStream);
end; end;
{ TsSpreadBIFF2Writer } { TsSpreadBIFF2Writer }
@ -74,6 +75,7 @@ implementation
const const
{ Excel record IDs } { Excel record IDs }
INT_EXCEL_ID_INTEGER = $0002;
INT_EXCEL_ID_NUMBER = $0003; INT_EXCEL_ID_NUMBER = $0003;
INT_EXCEL_ID_LABEL = $0004; INT_EXCEL_ID_LABEL = $0004;
INT_EXCEL_ID_FORMULA = $0006; INT_EXCEL_ID_FORMULA = $0006;
@ -392,11 +394,13 @@ begin
case RecordType of case RecordType of
INT_EXCEL_ID_INTEGER: ReadInteger(AStream);
INT_EXCEL_ID_NUMBER: ReadNumber(AStream); INT_EXCEL_ID_NUMBER: ReadNumber(AStream);
INT_EXCEL_ID_LABEL: ReadLabel(AStream); INT_EXCEL_ID_LABEL: ReadLabel(AStream);
INT_EXCEL_ID_FORMULA: ReadFormula(AStream); INT_EXCEL_ID_FORMULA: ReadFormula(AStream);
INT_EXCEL_ID_BOF: ; INT_EXCEL_ID_BOF: ;
INT_EXCEL_ID_EOF: BIFF2EOF := True; INT_EXCEL_ID_EOF: BIFF2EOF := True;
else else
// nothing // nothing
end; end;
@ -460,6 +464,27 @@ begin
FWorksheet.WriteNumber(ARow, ACol, AValue); FWorksheet.WriteNumber(ARow, ACol, AValue);
end; 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 * Initialization section
* *
@ -472,4 +497,3 @@ initialization
RegisterSpreadFormat(TsSpreadBIFF2Reader, TsSpreadBIFF2Writer, sfExcel2); RegisterSpreadFormat(TsSpreadBIFF2Reader, TsSpreadBIFF2Writer, sfExcel2);
end. end.