diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index b05a6e386..e2b41d58b 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -95,7 +95,6 @@ type procedure ReadRKValue(const AStream: TStream); procedure ReadMulRKValues(const AStream: TStream); - procedure ReadFormulaExcel(AStream: TStream); procedure ReadRowColXF(const AStream: TStream; out ARow,ACol,AXF: WORD); function ReadString(const AStream: TStream; const ALength: WORD): UTF8String; procedure ReadRichString(const AStream: TStream); @@ -1518,12 +1517,18 @@ begin INT_EXCEL_ID_NUMBER: ReadNumber(AStream); INT_EXCEL_ID_LABEL: ReadLabel(AStream); -// INT_EXCEL_ID_FORMULA: ReadFormula(AStream); - INT_EXCEL_ID_RSTRING: ReadRichString(AStream); //(RSTRING) This record stores a formatted text cell (Rich-Text). In BIFF8 it is usually replaced by the LABELSST record. Excel still uses this record, if it copies formatted text cells to the clipboard. - INT_EXCEL_ID_RK: ReadRKValue(AStream); //(RK) This record represents a cell that contains an RK value (encoded integer or floating-point value). If a floating-point value cannot be encoded to an RK value, a NUMBER record will be written. This record replaces the record INTEGER written in BIFF2. + INT_EXCEL_ID_FORMULA: ReadFormula(AStream); + //(RSTRING) This record stores a formatted text cell (Rich-Text). + // In BIFF8 it is usually replaced by the LABELSST record. Excel still + // uses this record, if it copies formatted text cells to the clipboard. + INT_EXCEL_ID_RSTRING: ReadRichString(AStream); + // (RK) This record represents a cell that contains an RK value + // (encoded integer or floating-point value). If a floating-point + // value cannot be encoded to an RK value, a NUMBER record will be written. + // This record replaces the record INTEGER written in BIFF2. + INT_EXCEL_ID_RK: ReadRKValue(AStream); INT_EXCEL_ID_MULRK: ReadMulRKValues(AStream); INT_EXCEL_ID_LABELSST:ReadLabelSST(AStream); //BIFF8 only - INT_EXCEL_ID_FORMULA: ReadFormulaExcel(AStream); INT_EXCEL_ID_BOF: ; INT_EXCEL_ID_EOF: SectionEOF := True; else @@ -1625,46 +1630,6 @@ begin end; end; -procedure TsSpreadBIFF8Reader.ReadFormulaExcel(AStream: TStream); -var - ARow, ACol, XF: WORD; - ResultFormula: Double; - Data: array [0..7] of BYTE; - Flags: WORD; - FormulaSize: BYTE; - i: Integer; -begin - { BIFF Record header } - { BIFF Record data } - { Index to XF Record } - ReadRowColXF(AStream,ARow,ACol,XF); - - { Result of the formula in IEE 754 floating-point value } - AStream.ReadBuffer(Data,Sizeof(Data)); - - { Options flags } - Flags:=WordLEtoN(AStream.ReadWord); - - { Not used } - AStream.ReadDWord; - - { Formula size } - FormulaSize := WordLEtoN(AStream.ReadWord); - - { Formula data, outputed as debug info } -{ Write('Formula Element: '); - for i := 1 to FormulaSize do - Write(IntToHex(AStream.ReadByte, 2) + ' '); - WriteLn('');} - - //RPN data not used by now - AStream.Position:=AStream.Position+FormulaSize; - - if SizeOf(Double)<>8 then Raise Exception.Create('Double is not 8 bytes'); - Move(Data[0],ResultFormula,sizeof(Data)); - FWorksheet.WriteNumber(ARow,ACol,ResultFormula); -end; - procedure TsSpreadBIFF8Reader.ReadRowColXF(const AStream: TStream; out ARow, ACol, AXF: WORD); begin @@ -1768,8 +1733,43 @@ begin end; procedure TsSpreadBIFF8Reader.ReadFormula(AStream: TStream); +var + ARow, ACol, XF: WORD; + ResultFormula: Double; + Data: array [0..7] of BYTE; + Flags: WORD; + FormulaSize: BYTE; + i: Integer; begin + { BIFF Record header } + { BIFF Record data } + { Index to XF Record } + ReadRowColXF(AStream,ARow,ACol,XF); + { Result of the formula in IEE 754 floating-point value } + AStream.ReadBuffer(Data,Sizeof(Data)); + + { Options flags } + Flags:=WordLEtoN(AStream.ReadWord); + + { Not used } + AStream.ReadDWord; + + { Formula size } + FormulaSize := WordLEtoN(AStream.ReadWord); + + { Formula data, outputed as debug info } +{ Write('Formula Element: '); + for i := 1 to FormulaSize do + Write(IntToHex(AStream.ReadByte, 2) + ' '); + WriteLn('');} + + //RPN data not used by now + AStream.Position:=AStream.Position+FormulaSize; + + if SizeOf(Double)<>8 then Raise Exception.Create('Double is not 8 bytes'); + Move(Data[0],ResultFormula,sizeof(Data)); + FWorksheet.WriteNumber(ARow,ACol,ResultFormula); end; procedure TsSpreadBIFF8Reader.ReadLabel(AStream: TStream);