fpspreadsheet: Read entire biff record of label and number cells to speed up reading (30% improvement for biff2). Numerous clean-up, mostly debugger settings.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3355 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2014-07-21 20:33:25 +00:00
parent 7fe3c4402a
commit ba37ace85f
24 changed files with 188 additions and 288 deletions

View File

@ -54,10 +54,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -52,10 +52,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -41,7 +41,6 @@
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>

View File

@ -28,21 +28,19 @@
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<RequiredPackages Count="2">
<Item1>
<PackageName Value="SQLDBLaz"/>
<PackageName Value="laz_fpspreadsheet"/>
</Item1>
<Item2>
<PackageName Value="laz_fpspreadsheet"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="fpsspeedtest.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpsspeedtest"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>

View File

@ -66,9 +66,6 @@
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>

View File

@ -48,9 +48,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item2>
<Item3 Name="Release">
@ -82,9 +79,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item3>
</BuildModes>
@ -134,18 +128,12 @@
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="5">

View File

@ -63,7 +63,7 @@ object Form1: TForm1
TabOrder = 1
TitleStyle = tsNative
ColWidths = (
56
42
64
64
64
@ -104,19 +104,19 @@ object Form1: TForm1
TabOrder = 2
object Label1: TLabel
Left = 8
Height = 20
Height = 15
Top = 9
Width = 46
Width = 37
Caption = 'Sheets:'
ParentColor = False
end
object SheetsCombo: TComboBox
Left = 72
Height = 28
Height = 23
Top = 4
Width = 808
Anchors = [akTop, akLeft, akRight]
ItemHeight = 20
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'Sheet 1'

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids, ColorBox, Buttons,
StdCtrls, Menus, ExtCtrls, ActnList, Spin, Buttons,
ButtonPanel, fpspreadsheetgrid, fpspreadsheet, fpsallformats;
type
@ -31,16 +31,6 @@ type
private
{ private declarations }
procedure LoadFile(const AFileName: String);
procedure SetupBackgroundColorBox;
procedure UpdateBackgroundColorIndex;
procedure UpdateFontNameIndex;
procedure UpdateFontSizeIndex;
procedure UpdateFontStyleActions;
procedure UpdateHorAlignmentActions;
procedure UpdateNumFormatActions;
procedure UpdateTextRotationActions;
procedure UpdateVertAlignmentActions;
procedure UpdateWordwraps;
public
{ public declarations }
end;
@ -60,7 +50,6 @@ procedure TForm1.BtnNewClick(Sender: TObject);
var
dlg: TForm;
edCols, edRows: TSpinEdit;
x: Integer;
begin
dlg := TForm.Create(nil);
try
@ -73,7 +62,7 @@ begin
Parent := dlg;
Left := dlg.ClientWidth - Width - 24;
Top := 16;
Value := WorksheetGrid.ColCount - ord(WorksheetGrid.DisplayFixedColRow);
Value := WorksheetGrid.ColCount - ord(WorksheetGrid.ShowHeaders);
end;
with TLabel.Create(dlg) do begin
Parent := dlg;
@ -87,7 +76,7 @@ begin
Parent := dlg;
Left := edCols.Left;
Top := edCols.Top + edCols.Height + 8;
Value := WorksheetGrid.RowCount - ord(WorksheetGrid.DisplayFixedColRow);
Value := WorksheetGrid.RowCount - ord(WorksheetGrid.ShowHeaders);
end;
with TLabel.Create(dlg) do begin
Parent := dlg;
@ -142,8 +131,6 @@ end;
// Loads first worksheet from file into grid
procedure TForm1.LoadFile(const AFileName: String);
var
i: Integer;
begin
// Load file
Screen.Cursor := crHourglass;
@ -166,55 +153,6 @@ begin
end;
end;
procedure TForm1.SetupBackgroundColorBox;
begin
end;
procedure TForm1.UpdateBackgroundColorIndex;
begin
end;
procedure TForm1.UpdateFontNameIndex;
begin
end;
procedure TForm1.UpdateFontSizeIndex;
begin
end;
procedure TForm1.UpdateFontStyleActions;
begin
end;
procedure TForm1.UpdateHorAlignmentActions;
begin
end;
procedure TForm1.UpdateNumFormatActions;
begin
end;
procedure TForm1.UpdateTextRotationActions;
begin
end;
procedure TForm1.UpdateVertAlignmentActions;
begin
end;
procedure TForm1.UpdateWordwraps;
begin
end;
initialization
{$I mainform.lrs}

View File

@ -54,10 +54,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -64,12 +64,10 @@
<Unit0>
<Filename Value="test_formula_func.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="test_formula_func"/>
</Unit0>
<Unit1>
<Filename Value="financemath.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="financemath"/>
</Unit1>
</Units>
</ProjectOptions>
@ -82,11 +80,6 @@
<CodeGeneration>
<SmartLinkUnit Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -77,9 +77,6 @@
<SmartLinkUnit Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>

View File

@ -77,7 +77,6 @@
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
<UseHeaptrc Value="True"/>
</Debugging>
</Linking>

View File

@ -4,7 +4,7 @@ object Form1: TForm1
Top = 248
Width = 884
Caption = 'spready'
ClientHeight = 624
ClientHeight = 629
ClientWidth = 884
Menu = MainMenu
OnActivate = FormActivate
@ -14,7 +14,7 @@ object Form1: TForm1
object Panel1: TPanel
Left = 0
Height = 85
Top = 539
Top = 544
Width = 884
Align = alBottom
BevelOuter = bvNone
@ -23,9 +23,9 @@ object Form1: TForm1
TabOrder = 0
object CbShowHeaders: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 8
Width = 116
Width = 93
Caption = 'Show headers'
Checked = True
OnClick = CbShowHeadersClick
@ -34,9 +34,9 @@ object Form1: TForm1
end
object CbShowGridLines: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 32
Width = 125
Width = 100
Caption = 'Show grid lines'
Checked = True
OnClick = CbShowGridLinesClick
@ -45,7 +45,7 @@ object Form1: TForm1
end
object EdFrozenCols: TSpinEdit
Left = 389
Height = 28
Height = 23
Top = 8
Width = 52
OnChange = EdFrozenColsChange
@ -53,7 +53,7 @@ object Form1: TForm1
end
object EdFrozenRows: TSpinEdit
Left = 389
Height = 28
Height = 23
Top = 39
Width = 52
OnChange = EdFrozenRowsChange
@ -61,37 +61,37 @@ object Form1: TForm1
end
object Label1: TLabel
Left = 304
Height = 20
Height = 15
Top = 13
Width = 77
Width = 62
Caption = 'Frozen cols:'
FocusControl = EdFrozenCols
ParentColor = False
end
object Label2: TLabel
Left = 304
Height = 20
Height = 15
Top = 40
Width = 82
Width = 66
Caption = 'Frozen rows:'
FocusControl = EdFrozenRows
ParentColor = False
end
object CbReadFormulas: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 56
Width = 120
Width = 96
Caption = 'Read formulas'
OnChange = CbReadFormulasChange
TabOrder = 4
end
object CbHeaderStyle: TComboBox
Left = 152
Height = 28
Height = 23
Top = 8
Width = 116
ItemHeight = 20
ItemHeight = 15
ItemIndex = 2
Items.Strings = (
'Lazarus'
@ -106,7 +106,7 @@ object Form1: TForm1
end
object PageControl1: TPageControl
Left = 0
Height = 460
Height = 465
Top = 79
Width = 884
ActivePage = TabSheet1
@ -116,11 +116,11 @@ object Form1: TForm1
OnChange = PageControl1Change
object TabSheet1: TTabSheet
Caption = 'Sheet1'
ClientHeight = 427
ClientHeight = 437
ClientWidth = 876
object WorksheetGrid: TsWorksheetGrid
Left = 0
Height = 427
Height = 437
Top = 0
Width = 876
FrozenCols = 0
@ -136,7 +136,7 @@ object Form1: TForm1
TitleStyle = tsNative
OnSelection = WorksheetGridSelection
ColWidths = (
56
42
64
64
64
@ -244,19 +244,19 @@ object Form1: TForm1
end
object FontComboBox: TComboBox
Left = 52
Height = 28
Height = 23
Top = 2
Width = 127
ItemHeight = 20
ItemHeight = 15
OnSelect = FontComboBoxSelect
TabOrder = 0
end
object FontSizeComboBox: TComboBox
Left = 179
Height = 28
Height = 23
Top = 2
Width = 48
ItemHeight = 20
ItemHeight = 15
Items.Strings = (
'8'
'9'

View File

@ -48,9 +48,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item2>
<Item3 Name="Release">
@ -82,9 +79,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item3>
</BuildModes>
@ -99,13 +93,16 @@
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<RequiredPackages Count="3">
<Item1>
<PackageName Value="laz_fpspreadsheet_visual"/>
<PackageName Value="laz_fpspreadsheet"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
<PackageName Value="laz_fpspreadsheet_visual"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
@ -134,18 +131,12 @@
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="5">

View File

@ -4,7 +4,7 @@ program spready;
uses
Interfaces, // this includes the LCL widgetset
Forms, mainform, laz_fpspreadsheet_visual;
Forms, mainform, laz_fpspreadsheet_visual, laz_fpspreadsheet;
{$R *.res}

View File

@ -38,7 +38,6 @@
<Unit0>
<Filename Value="wikitableread.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="wikitableread"/>
</Unit0>
</Units>
</ProjectOptions>
@ -53,13 +52,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -54,10 +54,5 @@
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsStabs"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -3046,13 +3046,12 @@ procedure TsSpreadOpenDocWriter.WriteRowStyles(AStream: TStream);
var
i: Integer;
rowstyle: TRowStyleData;
s: String;
useOptRowH: String;
begin
if FRowStyleList.Count = 0 then begin
AppendToStream(AStream,
'<style:style style:name="ro1" style:family="table-row">',
'<style:table-row-properties style:row-height="0.416cm" fo:break-before="auto" style:use-optimal-row-height="true"/>',
'<style:style style:name="ro1" style:family="table-row">' +
'<style:table-row-properties style:row-height="0.416cm" fo:break-before="auto" style:use-optimal-row-height="true"/>' +
'</style:style>');
exit;
end;

View File

@ -63,56 +63,56 @@ This package is all you need if you don't want graphical components (like grids
<UnitName Value="fpsutils"/>
</Item9>
<Item10>
<Filename Value="fpszipper.pp"/>
<UnitName Value="fpszipper"/>
</Item10>
<Item11>
<Filename Value="uvirtuallayer_types.pas"/>
<UnitName Value="uvirtuallayer_types"/>
</Item11>
<Item12>
<Filename Value="uvirtuallayer.pas"/>
<UnitName Value="uvirtuallayer"/>
</Item12>
<Item13>
<Filename Value="uvirtuallayer_ole.pas"/>
<UnitName Value="uvirtuallayer_ole"/>
</Item13>
<Item14>
<Filename Value="uvirtuallayer_ole_helpers.pas"/>
<UnitName Value="uvirtuallayer_ole_helpers"/>
</Item14>
<Item15>
<Filename Value="uvirtuallayer_ole_types.pas"/>
<UnitName Value="uvirtuallayer_ole_types"/>
</Item15>
<Item16>
<Filename Value="uvirtuallayer_stream.pas"/>
<UnitName Value="uvirtuallayer_stream"/>
</Item16>
<Item17>
<Filename Value="fpolebasic.pas"/>
<UnitName Value="fpolebasic"/>
</Item17>
<Item18>
<Filename Value="xlscommon.pas"/>
<UnitName Value="xlscommon"/>
</Item18>
<Item19>
<Filename Value="wikitable.pas"/>
<UnitName Value="wikitable"/>
</Item19>
<Item20>
<Filename Value="fpsnumformatparser.pas"/>
<UnitName Value="fpsNumFormatParser"/>
</Item20>
<Item21>
<Filename Value="fpsfunc.pas"/>
<UnitName Value="fpsfunc"/>
</Item21>
<Item22>
<Filename Value="fpsstreams.pas"/>
<UnitName Value="fpsStreams"/>
</Item10>
<Item11>
<Filename Value="fpszipper.pp"/>
<UnitName Value="fpszipper"/>
</Item11>
<Item12>
<Filename Value="uvirtuallayer_types.pas"/>
<UnitName Value="uvirtuallayer_types"/>
</Item12>
<Item13>
<Filename Value="uvirtuallayer.pas"/>
<UnitName Value="uvirtuallayer"/>
</Item13>
<Item14>
<Filename Value="uvirtuallayer_ole.pas"/>
<UnitName Value="uvirtuallayer_ole"/>
</Item14>
<Item15>
<Filename Value="uvirtuallayer_ole_helpers.pas"/>
<UnitName Value="uvirtuallayer_ole_helpers"/>
</Item15>
<Item16>
<Filename Value="uvirtuallayer_ole_types.pas"/>
<UnitName Value="uvirtuallayer_ole_types"/>
</Item16>
<Item17>
<Filename Value="uvirtuallayer_stream.pas"/>
<UnitName Value="uvirtuallayer_stream"/>
</Item17>
<Item18>
<Filename Value="fpolebasic.pas"/>
<UnitName Value="fpolebasic"/>
</Item18>
<Item19>
<Filename Value="xlscommon.pas"/>
<UnitName Value="xlscommon"/>
</Item19>
<Item20>
<Filename Value="wikitable.pas"/>
<UnitName Value="wikitable"/>
</Item20>
<Item21>
<Filename Value="fpsnumformatparser.pas"/>
<UnitName Value="fpsNumFormatParser"/>
</Item21>
<Item22>
<Filename Value="fpsfunc.pas"/>
<UnitName Value="fpsfunc"/>
</Item22>
</Files>
<RequiredPkgs Count="2">

View File

@ -8,10 +8,10 @@ interface
uses
fpolestorage, fpsallformats, fpsopendocument, fpspreadsheet, xlsbiff2,
xlsbiff5, xlsbiff8, xlsxooxml, fpsutils, fpszipper, uvirtuallayer_types,
uvirtuallayer, uvirtuallayer_ole, uvirtuallayer_ole_helpers,
uvirtuallayer_ole_types, uvirtuallayer_stream, fpolebasic, xlscommon,
wikitable, fpsNumFormatParser, fpsfunc, fpsStreams;
xlsbiff5, xlsbiff8, xlsxooxml, fpsutils, fpsStreams, fpszipper,
uvirtuallayer_types, uvirtuallayer, uvirtuallayer_ole,
uvirtuallayer_ole_helpers, uvirtuallayer_ole_types, uvirtuallayer_stream,
fpolebasic, xlscommon, wikitable, fpsNumFormatParser, fpsfunc;
implementation

View File

@ -167,6 +167,29 @@ const
INT_EXCEL_CHART = $0020;
INT_EXCEL_MACRO_SHEET = $0040;
type
TBIFF2LabelRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
Attrib1: Byte;
Attrib2: Byte;
Attrib3: Byte;
TextLen: Byte;
end;
TBIFF2NumberRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
Attrib1: Byte;
Attrib2: Byte;
Attrib3: Byte;
Value: Double;
end;
{ TsBIFF2NumFormatList }
@ -541,19 +564,23 @@ end;
procedure TsSpreadBIFF2Reader.ReadLabel(AStream: TStream);
var
rec: TBIFF2LabelRecord;
L: Byte;
ARow, ACol: Cardinal;
XF: Word;
AValue: array[0..255] of Char;
AValue: ansistring;
AStrValue: UTF8String;
begin
{ BIFF Record row/column/style }
ReadRowColXF(AStream, ARow, ACol, XF);
{ Read entire record, starting at Row, except for string data }
AStream.ReadBuffer(rec.Row, SizeOf(TBIFF2LabelRecord) - 2*SizeOf(Word));
ARow := WordLEToN(rec.Row);
ACol := WordLEToN(rec.Col);
XF := rec.Attrib1 and $3F;
{ String with 8-bit size }
L := AStream.ReadByte();
AStream.ReadBuffer(AValue, L);
AValue[L] := #0;
L := rec.TextLen;
SetLength(AValue, L);
AStream.ReadBuffer(AValue[1], L);
{ Save the data }
case WorkBookEncoding of
@ -575,6 +602,7 @@ end;
procedure TsSpreadBIFF2Reader.ReadNumber(AStream: TStream);
var
rec: TBIFF2NumberRecord;
ARow, ACol: Cardinal;
XF: Word;
value: Double = 0.0;
@ -582,11 +610,12 @@ var
nf: TsNumberFormat;
nfs: String;
begin
{ BIFF Record row/column/style }
ReadRowColXF(AStream, ARow, ACol, XF);
{ IEE 754 floating-point value }
AStream.ReadBuffer(value, 8);
{ Read entire record, starting at Row }
AStream.ReadBuffer(rec.Row, SizeOf(TBIFF2NumberRecord) - 2*SizeOf(Word));
ARow := WordLEToN(rec.Row);
ACol := WordLEToN(rec.Col);
XF := rec.Attrib1 and $3F;
value := rec.Value;
{Find out what cell type, set content type and value}
ExtractNumberFormat(XF, nf, nfs);
@ -1560,24 +1589,13 @@ end;
*******************************************************************}
procedure TsSpreadBIFF2Writer.WriteLabel(AStream: TStream; const ARow,
ACol: Cardinal; const AValue: string; ACell: PCell);
type
TLabelRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
Attrib1: Byte;
Attrib2: Byte;
Attrib3: Byte;
TextLen: Byte;
end;
const
MAXBYTES = 255; //limit for this format
var
L: Byte;
AnsiText: ansistring;
TextTooLong: boolean=false;
rec: TLabelRecord;
rec: TBIFF2LabelRecord;
buf: array of byte;
var
xf: Word;
@ -1659,20 +1677,9 @@ end;
*******************************************************************}
procedure TsSpreadBIFF2Writer.WriteNumber(AStream: TStream; const ARow,
ACol: Cardinal; const AValue: double; ACell: PCell);
type
TNumberRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
Attrib1: Byte;
Attrib2: Byte;
Attrib3: Byte;
Value: Double;
end;
var
xf: Word;
rec: TNumberRecord;
rec: TBIFF2NumberRecord;
begin
xf := FindXFIndex(ACell);
if xf >= 63 then

View File

@ -307,6 +307,16 @@ const
XF_ROTATION_STACKED
);
type
TBIFF5LabelRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
XFIndex: Word;
TextLen: Word;
end;
{ TsSpreadBIFF5Writer }
@ -933,22 +943,13 @@ end;
*******************************************************************}
procedure TsSpreadBIFF5Writer.WriteLabel(AStream: TStream; const ARow,
ACol: Cardinal; const AValue: string; ACell: PCell);
type
TLabelRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
XFIndex: Word;
TextLen: Word;
end;
const
MAXBYTES = 255; //limit for this format
var
L: Word;
AnsiValue: ansistring;
TextTooLong: boolean=false;
rec: TLabelRecord;
rec: TBIFF5LabelRecord;
buf: array of byte;
begin
case WorkBookEncoding of
@ -1756,12 +1757,29 @@ end;
procedure TsSpreadBIFF5Reader.ReadLabel(AStream: TStream);
var
rec: TBIFF5LabelRecord;
L: Word;
ARow, ACol: Cardinal;
XF: WORD;
AValue: array[0..255] of Char;
// AValue: array[0..255] of Char;
AValue: ansistring;
AStrValue: ansistring;
begin
{ Read entire record, starting at Row, except for string data }
AStream.ReadBuffer(rec.Row, SizeOf(TBIFF5LabelRecord) - 2*SizeOf(Word));
ARow := WordLEToN(rec.Row);
ACol := WordLEToN(rec.Col);
XF := WordLEToN(rec.XFIndex);
{ Byte String with 16-bit size }
L := WordLEToN(rec.TextLen);
SetLength(AValue, L);
AStream.ReadBuffer(AValue[1], L);
{ Save the data }
FWorksheet.WriteUTF8Text(ARow, ACol, ISO_8859_1ToUTF8(AValue));
(*
ReadRowColXF(AStream, ARow, ACol, XF);
{ Byte String with 16-bit size }
@ -1772,7 +1790,7 @@ begin
{ Save the data }
FWorksheet.WriteUTF8Text(ARow, ACol, ISO_8859_1ToUTF8(AStrValue));
*)
{ Add attributes }
ApplyCellFormatting(ARow, ACol, XF);
end;

View File

@ -677,6 +677,15 @@ const
INT_EXCEL_TOKEN_TATTR {fekOpSum}
);
type
TBIFF58NumberRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
XFIndex: Word;
Value: Double;
end;
function ConvertExcelDateTimeToDateTime(
const AExcelDateNum: Double; ADateMode: TDateMode): TDateTime;
@ -1230,6 +1239,7 @@ end;
// NOTE: This procedure is valid after BIFF 3.
procedure TsSpreadBIFFReader.ReadNumber(AStream: TStream);
var
rec: TBIFF58NumberRecord;
ARow, ACol: Cardinal;
XF: WORD;
value: Double = 0.0;
@ -1237,10 +1247,18 @@ var
nf: TsNumberFormat;
nfs: String;
begin
{ Read entire record, starting at Row }
AStream.ReadBuffer(rec.Row, SizeOf(TBIFF58NumberRecord) - 2*SizeOf(Word));
ARow := WordLEToN(rec.Row);
ACol := WordLEToN(rec.Col);
XF := WordLEToN(rec.XFIndex);
value := rec.Value;
(*
ReadRowColXF(AStream, ARow, ACol, XF);
{ IEE 754 floating-point value }
AStream.ReadBuffer(value, 8);
*)
{Find out what cell type, set content type and value}
ExtractNumberFormat(XF, nf, nfs);
@ -1921,17 +1939,8 @@ end;
Valid for BIFF5 and BIFF8 (BIFF2 has a different record structure.). }
procedure TsSpreadBIFFWriter.WriteNumber(AStream: TStream;
const ARow, ACol: Cardinal; const AValue: double; ACell: PCell);
type
TNumberRecord = packed record
RecordID: Word;
RecordSize: Word;
Row: Word;
Col: Word;
XFIndex: Word;
Value: Double;
end;
var
rec: TNumberRecord;
rec: TBIFF58NumberRecord;
begin
{ BIFF Record header }
rec.RecordID := WordToLE(INT_EXCEL_ID_NUMBER);

View File

@ -243,8 +243,6 @@ procedure TsSpreadOOXMLWriter.AddDefaultFormats();
// We store the index of the XF record that will be assigned to this style in
// the "row" of the style. Will be needed when writing the XF record.
// --- This is needed for BIFF. Not clear if it is important here as well...
var
len: Integer;
begin
SetLength(FFormattingStyles, 2);
@ -559,7 +557,6 @@ var
item: TsNumFormatData;
s: String;
n: Integer;
fmt: String;
begin
s := '';
n := 0;
@ -1066,7 +1063,6 @@ end;
{ Is called before zipping the individual file parts. Rewinds the streams. }
procedure TsSpreadOOXMLWriter.ResetStreams;
var
stream: TStream;
i: Integer;
begin
ResetStream(FSContentTypes);