fpspreadsheet: Reducing hints and warnings, still a lot...

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3203 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-06-19 19:25:40 +00:00
parent 888f605851
commit a85adcb61a
24 changed files with 139 additions and 328 deletions

View File

@ -105,7 +105,6 @@
<Unit0> <Unit0>
<Filename Value="fpsgrid.lpr"/> <Filename Value="fpsgrid.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value=""/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="mainform.pas"/> <Filename Value="mainform.pas"/>
@ -113,6 +112,7 @@
<ComponentName Value="Form1"/> <ComponentName Value="Form1"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="mainform"/>
</Unit1> </Unit1>
</Units> </Units>
</ProjectOptions> </ProjectOptions>

View File

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

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids, graphutil, StdCtrls, Menus, ExtCtrls, ComCtrls, ActnList, Spin, Grids,
ColorBox, fpspreadsheetgrid, fpspreadsheet, fpsallformats; ColorBox, fpspreadsheetgrid, fpspreadsheet, fpsallformats;
type type
@ -873,7 +873,6 @@ var
cell: PCell; cell: PCell;
r,c: Cardinal; r,c: Cardinal;
found: Boolean; found: Boolean;
t: Integer;
begin begin
with WorksheetGrid do begin with WorksheetGrid do begin
r := GetWorksheetRow(Row); r := GetWorksheetRow(Row);
@ -885,7 +884,6 @@ begin
nf := cell^.NumberFormat; nf := cell^.NumberFormat;
for i:=0 to ActionList.ActionCount-1 do begin for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]); ac := TAction(ActionList.Actions[i]);
t := ac.Tag;
if (ac.Tag >= NUMFMT_TAG) and (ac.Tag < NUMFMT_TAG + 200) then begin if (ac.Tag >= NUMFMT_TAG) and (ac.Tag < NUMFMT_TAG + 200) then begin
found := ((ac.Tag - NUMFMT_TAG) div 10 = ord(nf)); found := ((ac.Tag - NUMFMT_TAG) div 10 = ord(nf));
if nf = nfCustom then if nf = nfCustom then
@ -921,12 +919,10 @@ var
i: Integer; i: Integer;
ac: TAction; ac: TAction;
vert_align: TsVertAlignment; vert_align: TsVertAlignment;
t: Integer;
begin begin
with WorksheetGrid do vert_align := VertAlignments[Selection]; with WorksheetGrid do vert_align := VertAlignments[Selection];
for i:=0 to ActionList.ActionCount-1 do begin for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]); ac := TAction(ActionList.Actions[i]);
t := ac.tag;
if (ac.Tag >= VERTALIGN_TAG) and (ac.Tag < VERTALIGN_TAG+10) then if (ac.Tag >= VERTALIGN_TAG) and (ac.Tag < VERTALIGN_TAG+10) then
ac.Checked := ((ac.Tag - VERTALIGN_TAG) = ord(vert_align)); ac.Checked := ((ac.Tag - VERTALIGN_TAG) = ord(vert_align));
end; end;

View File

@ -129,15 +129,15 @@ type
out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor); out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor);
function IsCurrencyAt(ASection: Integer; out ANumFormat: TsNumberFormat; function IsCurrencyAt(ASection: Integer; out ANumFormat: TsNumberFormat;
out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor): Boolean; out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor): Boolean;
function IsDateAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat; function IsDateAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
var ANextIndex: Integer): Boolean; var ANextIndex: Integer): Boolean;
function IsNumberAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat; function IsNumberAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
var ADecimals: Byte; var ANextIndex: Integer): Boolean; out ADecimals: Byte; out ANextIndex: Integer): Boolean;
function IsSciAt(ASection, AIndex: Integer; var ANumberFormat: TsNumberFormat; function IsSciAt(ASection, AIndex: Integer; out ANumberFormat: TsNumberFormat;
var ADecimals: Byte; var ANextIndex: Integer): Boolean; out ADecimals: Byte; out ANextIndex: Integer): Boolean;
function IsTextAt(AText: string; ASection, AIndex: Integer): Boolean; function IsTextAt(AText: string; ASection, AIndex: Integer): Boolean;
function IsTimeAt(ASection,AIndex: Integer; var ANumberFormat: TsNumberFormat; function IsTimeAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
var ANextIndex: Integer): Boolean; out ANextIndex: Integer): Boolean;
function IsTokenAt(AToken: TsNumFormatToken; ASection,AIndex: Integer): Boolean; function IsTokenAt(AToken: TsNumFormatToken; ASection,AIndex: Integer): Boolean;
public public
@ -309,10 +309,8 @@ function TsNumFormatParser.BuildFormatStringFromSection(ASection: Integer;
var var
element: TsNumFormatElement; element: TsNumFormatElement;
i: Integer; i: Integer;
colorAdded: Boolean;
begin begin
Result := ''; Result := '';
colorAdded := false;
if (ASection < 0) and (ASection >= GetParsedSectionCount) then if (ASection < 0) and (ASection >= GetParsedSectionCount) then
exit; exit;
@ -382,17 +380,9 @@ begin
scCyan : Result := '[cyan]'; scCyan : Result := '[cyan]';
else Result := Format('[Color%d]', [element.IntValue]); else Result := Format('[Color%d]', [element.IntValue]);
end; end;
colorAdded := true;
end; end;
end; end;
end; end;
{
if (ADialect = nfdExcel)
and (not colorAdded) and
(FSections[ASection].NumFormat in [nfCurrencyRed, nfAccountingRed])
then
Result := '[red]'+Result;
}
end; end;
procedure TsNumFormatParser.CheckSections; procedure TsNumFormatParser.CheckSections;
@ -406,7 +396,6 @@ end;
procedure TsNumFormatParser.CheckSection(ASection: Integer); procedure TsNumFormatParser.CheckSection(ASection: Integer);
var var
i, j: Integer; i, j: Integer;
ok: Boolean;
// Finds the previous date/time element skipping spaces, date/time sep etc. // Finds the previous date/time element skipping spaces, date/time sep etc.
function PrevDateTimeElement(j: Integer): Integer; function PrevDateTimeElement(j: Integer): Integer;
@ -564,10 +553,7 @@ procedure TsNumFormatParser.EvalNumFormatOfSection(ASection: Integer;
out AColor: TsColor); out AColor: TsColor);
var var
nf: TsNumberFormat; nf: TsNumberFormat;
decs: Byte; next: Integer = 0;
cs: String;
next: Integer;
ampm: Boolean;
begin begin
ANumFormat := nfCustom; ANumFormat := nfCustom;
ADecimals := 0; ADecimals := 0;
@ -761,7 +747,6 @@ var
isAccounting : Boolean; isAccounting : Boolean;
hasCurrSymbol: Boolean; hasCurrSymbol: Boolean;
hasColor: Boolean; hasColor: Boolean;
next: Integer;
el: Integer; el: Integer;
begin begin
Result := false; Result := false;
@ -772,6 +757,7 @@ begin
AColor := scNotDefined; AColor := scNotDefined;
isAccounting := false; isAccounting := false;
hasColor := false; hasColor := false;
hasCurrSymbol := false;
// Looking for the currency symbol: it is the unique identifier of the // Looking for the currency symbol: it is the unique identifier of the
// currency format. // currency format.
@ -804,7 +790,10 @@ begin
nftRepeat: nftRepeat:
isAccounting := true; isAccounting := true;
nftCurrSymbol: nftCurrSymbol:
begin
ACurrencySymbol := FSections[ASection].Elements[el].TextValue; ACurrencySymbol := FSections[ASection].Elements[el].TextValue;
hasCurrSymbol := true;
end;
nftOptDigit: nftOptDigit:
if IsNumberAt(ASection, el, ANumFormat, ADecimals, el) then if IsNumberAt(ASection, el, ANumFormat, ADecimals, el) then
dec(el) dec(el)
@ -837,49 +826,10 @@ begin
end; end;
end else end else
ANumFormat := nfCustom; ANumFormat := nfCustom;
(*
if IsTokenAt(nftColor, ASection, AIndex) then begin
AIndex := AIndex + 1;
AColor := FSections[ASection].Elements[AIndex].IntValue;
end;
isAccounting := false;
hasCurrSymbol := false;
while (AIndex < Length(FSections[ASection].Elements)) do begin
case FSections[ASection].Elements[AIndex].Token of
nftRepeat:
isAccounting := true;
nftCurrSymbol:
begin
hasCurrSymbol := true;
ACurrencySymbol := FSections[ASection].Elements[AIndex].TextValue;
end;
nftOptDigit:
if IsNumberAt(ASection, AIndex, ANumFormat, ADecimals, next) then
AIndex := next-1
else
exit;
end;
inc(AIndex);
end;
Result := hasCurrSymbol and (ANumFormat = nfFixedTh);
if Result then begin
if isAccounting then begin
if AColor = scNotDefined then ANumFormat := nfAccounting else
if AColor = scRed then ANumFormat := nfAccountingRed;
end else begin
if AColor = scNotDefined then ANumFormat := nfCurrency else
if AColor = scRed then ANumFormat := nfCurrencyRed;
end;
end else
ANumFormat := nfCustom;
*)
end; end;
function TsNumFormatParser.IsDateAt(ASection,AIndex: Integer; function TsNumFormatParser.IsDateAt(ASection,AIndex: Integer;
var ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean; out ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean;
function CheckFormat(AFmtStr: String; var idx: Integer): Boolean; function CheckFormat(AFmtStr: String; var idx: Integer): Boolean;
var var
@ -936,8 +886,6 @@ function TsNumFormatParser.IsDateAt(ASection,AIndex: Integer;
ANextIndex := idx; ANextIndex := idx;
end; end;
var
i: Integer;
begin begin
if FWorkbook = nil then begin if FWorkbook = nil then begin
Result := false; Result := false;
@ -979,16 +927,13 @@ end;
at standard number format, like nfFixed, nfPercentage etc. at standard number format, like nfFixed, nfPercentage etc.
Returns TRUE if it does. } Returns TRUE if it does. }
function TsNumFormatParser.IsNumberAt(ASection,AIndex: Integer; function TsNumFormatParser.IsNumberAt(ASection,AIndex: Integer;
var ANumberFormat: TsNumberFormat; var ADecimals: Byte; out ANumberFormat: TsNumberFormat; out ADecimals: Byte;
var ANextIndex: Integer): Boolean; out ANextIndex: Integer): Boolean;
var
nElem: Integer;
begin begin
Result := false; Result := false;
ANumberFormat := nfGeneral; ANumberFormat := nfGeneral;
ADecimals := 0; ADecimals := 0;
ANextIndex := MaxInt; ANextIndex := MaxInt;
nElem := Length(FSections[ASection].Elements);
// Let's look for digit tokens ('0') first // Let's look for digit tokens ('0') first
if IsTokenAt(nftDigit, ASection, AIndex) then begin // '0' if IsTokenAt(nftDigit, ASection, AIndex) then begin // '0'
if IsTokenAt(nftDecSep, ASection, AIndex+1) and // '.' if IsTokenAt(nftDecSep, ASection, AIndex+1) and // '.'
@ -1035,7 +980,7 @@ begin
end; end;
function TsNumFormatParser.IsSciAt(ASection, AIndex: Integer; function TsNumFormatParser.IsSciAt(ASection, AIndex: Integer;
var ANumberFormat: TsNumberFormat; var ADecimals: Byte; var ANextIndex: Integer): Boolean; out ANumberFormat: TsNumberFormat; out ADecimals: Byte; out ANextIndex: Integer): Boolean;
begin begin
if IsTokenAt(nftOptDigit, ASection, AIndex) and // '#' if IsTokenAt(nftOptDigit, ASection, AIndex) and // '#'
IsTokenAt(nftOptDigit, ASection, Aindex+1) and // '#' IsTokenAt(nftOptDigit, ASection, Aindex+1) and // '#'
@ -1061,10 +1006,10 @@ begin
end; end;
function TsNumFormatParser.IsTimeAt(ASection,AIndex: Integer; function TsNumFormatParser.IsTimeAt(ASection,AIndex: Integer;
var ANumberFormat: TsNumberFormat; var ANextIndex: Integer): Boolean; out ANumberFormat: TsNumberFormat; out ANextIndex: Integer): Boolean;
function CheckFormat(AFmtStr: String; var idx: Integer; function CheckFormat(AFmtStr: String; var idx: Integer;
var AMPM, IsInterval: boolean): Boolean; out AMPM, IsInterval: boolean): Boolean;
var var
i: Integer; i: Integer;
s: String; s: String;
@ -1143,7 +1088,6 @@ function TsNumFormatParser.IsTimeAt(ASection,AIndex: Integer;
end; end;
end; end;
Result := true; Result := true;
ANextIndex := idx;
end; end;
var var
@ -1252,12 +1196,9 @@ begin
end; end;
function TsNumFormatParser.NextToken: Char; function TsNumFormatParser.NextToken: Char;
var
delta: Integer;
begin begin
if FCurrent < FEnd then begin if FCurrent < FEnd then begin
inc(FCurrent); inc(FCurrent);
delta := integer(FCurrent - FStart);
Result := FCurrent^; Result := FCurrent^;
end else end else
Result := #0; Result := #0;
@ -1337,6 +1278,7 @@ var
n: Integer; n: Integer;
prevtoken: Char; prevtoken: Char;
begin begin
s := '';
FToken := NextToken; // Cursor was at '[' FToken := NextToken; // Cursor was at '['
while (FCurrent < FEnd) and (FStatus = psOK) do begin while (FCurrent < FEnd) and (FStatus = psOK) do begin
case FToken of case FToken of
@ -1471,10 +1413,8 @@ procedure TsNumFormatParser.ScanDateTime;
var var
n: Integer; n: Integer;
token: Char; token: Char;
delta: Integer;
begin begin
while (FCurrent < FEnd) and (FStatus = psOK) do begin while (FCurrent < FEnd) and (FStatus = psOK) do begin
delta := Integer(FCurrent - FStart);
case FToken of case FToken of
'\': // means that the next character is taken literally '\': // means that the next character is taken literally
begin begin
@ -1603,24 +1543,12 @@ end;
procedure TsNumFormatParser.ScanNumber; procedure TsNumFormatParser.ScanNumber;
var var
hasDecSep: Boolean; hasDecSep: Boolean;
hasThSep: Boolean;
hasExp: Boolean;
n: Integer; n: Integer;
delta: Integer;
begin begin
hasDecSep := false; hasDecSep := false;
hasThSep := false;
hasExp := false;
while (FCurrent < FEnd) and (FStatus = psOK) do begin while (FCurrent < FEnd) and (FStatus = psOK) do begin
delta := integer(FCurrent - FStart);
case FToken of case FToken of
',': begin ',': AddElement(nftThSep, ',');
AddElement(nftThSep, ',');
hasThSep := true;
end;
'.': begin '.': begin
AddElement(nftDecSep, '.'); AddElement(nftDecSep, '.');
hasDecSep := true; hasDecSep := true;

View File

@ -108,11 +108,11 @@ type
procedure ReadNumFormats(AStylesNode: TDOMNode); procedure ReadNumFormats(AStylesNode: TDOMNode);
procedure ReadStyles(AStylesNode: TDOMNode); procedure ReadStyles(AStylesNode: TDOMNode);
{ Record writing methods } { Record writing methods }
procedure ReadBlank(ARow, ACol: Word; ACellNode: TDOMNode); procedure ReadBlank(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
procedure ReadDateTime(ARow, ACol: Word; ACellNode: TDOMNode); procedure ReadDateTime(ARow, ACol: Word; ACellNode: TDOMNode);
procedure ReadFormula(ARow, ACol: Word; ACellNode: TDOMNode); procedure ReadFormula(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
procedure ReadLabel(ARow, ACol: Word; ACellNode: TDOMNode); procedure ReadLabel(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
procedure ReadNumber(ARow, ACol: Word; ACellNode: TDOMNode); procedure ReadNumber(ARow, ACol: Word; ACellNode: TDOMNode); reintroduce;
public public
{ General reading methods } { General reading methods }
constructor Create(AWorkbook: TsWorkbook); override; constructor Create(AWorkbook: TsWorkbook); override;
@ -1248,7 +1248,6 @@ var
cell: PCell; cell: PCell;
formula: String; formula: String;
stylename: String; stylename: String;
txtValue: String;
floatValue: Double; floatValue: Double;
fs: TFormatSettings; fs: TFormatSettings;
valueType: String; valueType: String;
@ -1470,7 +1469,7 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
procedure ReadNumberStyle(ANumFormatNode: TDOMNode; ANumFormatName: String); procedure ReadNumberStyle(ANumFormatNode: TDOMNode; ANumFormatName: String);
var var
node, childNode: TDOMNode; node, childNode: TDOMNode;
fmtName, nodeName: String; nodeName: String;
fmt: String; fmt: String;
nf: TsNumberFormat; nf: TsNumberFormat;
decs: Byte; decs: Byte;
@ -1478,8 +1477,6 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
grouping: Boolean; grouping: Boolean;
nex: Integer; nex: Integer;
cs: String; cs: String;
color: TsColorValue;
idx: Integer;
hasColor: Boolean; hasColor: Boolean;
begin begin
fmt := ''; fmt := '';
@ -1655,7 +1652,6 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
nf: TsNumberFormat; nf: TsNumberFormat;
fmt: String; fmt: String;
nodeName: String; nodeName: String;
s: String;
begin begin
fmt := ''; fmt := '';
node := ANumFormatNode.FirstChild; node := ANumFormatNode.FirstChild;
@ -1729,15 +1725,13 @@ var
cellNode, rowNode: TDOMNode; cellNode, rowNode: TDOMNode;
paramValueType, paramFormula, tableStyleName: String; paramValueType, paramFormula, tableStyleName: String;
paramColsRepeated, paramRowsRepeated: String; paramColsRepeated, paramRowsRepeated: String;
colsRepeated, rowsRepeated: Integer; rowsRepeated: Integer;
rowStyleName: String; rowStyleName: String;
rowStyleIndex: Integer; rowStyleIndex: Integer;
rowStyle: TRowStyleData; rowStyle: TRowStyleData;
rowHeight: Single; rowHeight: Single;
autoRowHeight: Boolean; autoRowHeight: Boolean;
i: Integer; i: Integer;
lRow: PRow;
s: String;
begin begin
rowsRepeated := 0; rowsRepeated := 0;
row := 0; row := 0;
@ -1860,8 +1854,6 @@ var
style: TCellStyleData; style: TCellStyleData;
styleNode: TDOMNode; styleNode: TDOMNode;
styleChildNode: TDOMNode; styleChildNode: TDOMNode;
colStyle: TColumnStyleData;
colWidth: Double;
family: String; family: String;
styleName: String; styleName: String;
styleIndex: Integer; styleIndex: Integer;
@ -1884,7 +1876,6 @@ var
var var
L: TStringList; L: TStringList;
i: Integer; i: Integer;
isSolid: boolean;
s: String; s: String;
wid: Double; wid: Double;
linestyle: String; linestyle: String;
@ -2405,22 +2396,7 @@ begin
end; end;
procedure TsSpreadOpenDocWriter.WriteWorksheet(CurSheet: TsWorksheet); procedure TsSpreadOpenDocWriter.WriteWorksheet(CurSheet: TsWorksheet);
var
j, k: Integer;
CurCell: PCell;
CurRow: array of PCell;
LastColIndex: Cardinal;
LCell: TCell;
AVLNode: TAVLTreeNode;
defFontSize: Single;
h, h_mm: Double;
styleName: String;
rowStyleData: TRowStyleData;
row: PRow;
begin begin
LastColIndex := CurSheet.GetLastColIndex;
defFontSize := Workbook.GetFont(0).Size;
// Header // Header
FContent := FContent + FContent := FContent +
' <table:table table:name="' + CurSheet.Name + '" table:style-name="ta1">' + LineEnding; ' <table:table table:name="' + CurSheet.Name + '" table:style-name="ta1">' + LineEnding;
@ -2495,7 +2471,6 @@ end;
function TsSpreadOpenDocWriter.WriteColStylesXMLAsString: string; function TsSpreadOpenDocWriter.WriteColStylesXMLAsString: string;
var var
i: Integer; i: Integer;
s: String;
colstyle: TColumnStyleData; colstyle: TColumnStyleData;
begin begin
Result := ''; Result := '';
@ -2608,10 +2583,7 @@ var
rowsRepeatedStr: String; rowsRepeatedStr: String;
lastCol, lastRow: Cardinal; lastCol, lastRow: Cardinal;
rowStyleData: TRowStyleData; rowStyleData: TRowStyleData;
colData: TColumnData;
colStyleData: TColumnStyleData;
defFontSize: Single; defFontSize: Single;
sameRowStyle: Boolean;
begin begin
Result := ''; Result := '';
@ -2716,7 +2688,6 @@ end;
function TsSpreadOpenDocWriter.WriteRowStylesXMLAsString: string; function TsSpreadOpenDocWriter.WriteRowStylesXMLAsString: string;
var var
i: Integer; i: Integer;
s: String;
rowstyle: TRowStyleData; rowstyle: TRowStyleData;
begin begin
Result := ''; Result := '';

View File

@ -601,7 +601,7 @@ type
{ Base methods } { Base methods }
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
class function GetFormatFromFileName(const AFileName: TFileName; var SheetType: TsSpreadsheetFormat): Boolean; class function GetFormatFromFileName(const AFileName: TFileName; out SheetType: TsSpreadsheetFormat): Boolean;
function CreateSpreadReader(AFormat: TsSpreadsheetFormat): TsCustomSpreadReader; function CreateSpreadReader(AFormat: TsSpreadsheetFormat): TsCustomSpreadReader;
function CreateSpreadWriter(AFormat: TsSpreadsheetFormat): TsCustomSpreadWriter; function CreateSpreadWriter(AFormat: TsSpreadsheetFormat): TsCustomSpreadWriter;
procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat); overload; procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat); overload;
@ -968,15 +968,15 @@ type
const const
FEProps: array[TFEKind] of TFEProp = ( FEProps: array[TFEKind] of TFEProp = (
{ Operands } { Operands }
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCell (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCell
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellRef (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellRef
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellRange (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellRange
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellNum (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellNum
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellInteger (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellInteger
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellString (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellString
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellBool (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellBool
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellErr (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellErr
(Symbol:''; MinParams:-1; MaxParams:-1), // fekCellMissingArg (Symbol:''; MinParams:-1; MaxParams:Byte(-1)), // fekCellMissingArg
{ Basic operations } { Basic operations }
(Symbol:'+'; MinParams:2; MaxParams:2), // fekAdd (Symbol:'+'; MinParams:2; MaxParams:2), // fekAdd
(Symbol:'-'; MinParams:2; MaxParams:2), // fekSub (Symbol:'-'; MinParams:2; MaxParams:2), // fekSub
@ -1587,7 +1587,6 @@ function TsWorksheet.ReadAsUTF8Text(ACell: PCell): ansistring;
var var
fs: TFormatSettings; fs: TFormatSettings;
left, right: String; left, right: String;
i: Integer;
begin begin
fs := FWorkbook.FormatSettings; fs := FWorkbook.FormatSettings;
if IsNan(Value) then if IsNan(Value) then
@ -1670,7 +1669,6 @@ end;
function TsWorksheet.ReadAsNumber(ARow, ACol: Cardinal): Double; function TsWorksheet.ReadAsNumber(ARow, ACol: Cardinal): Double;
var var
ACell: PCell; ACell: PCell;
Str: string;
begin begin
Result := 0.0; Result := 0.0;
ACell := FindCell(ARow, ACol); ACell := FindCell(ARow, ACol);
@ -1695,7 +1693,6 @@ end;
function TsWorksheet.ReadAsDateTime(ARow, ACol: Cardinal; out AResult: TDateTime): Boolean; function TsWorksheet.ReadAsDateTime(ARow, ACol: Cardinal; out AResult: TDateTime): Boolean;
var var
ACell: PCell; ACell: PCell;
Str: string;
begin begin
ACell := FindCell(ARow, ACol); ACell := FindCell(ARow, ACol);
@ -1724,7 +1721,6 @@ end;
function TsWorksheet.ReadRPNFormulaAsString(ACell: PCell): String; function TsWorksheet.ReadRPNFormulaAsString(ACell: PCell): String;
var var
fs: TFormatSettings; fs: TFormatSettings;
formula: TsRPNFormula;
elem: TsFormulaElement; elem: TsFormulaElement;
i, j: Integer; i, j: Integer;
L: TStringList; L: TStringList;
@ -1958,8 +1954,6 @@ end;
the file. } the file. }
procedure TsWorksheet.WriteNumber(ARow, ACol: Cardinal; ANumber: Double; procedure TsWorksheet.WriteNumber(ARow, ACol: Cardinal; ANumber: Double;
AFormat: TsNumberFormat; AFormatString: String); AFormat: TsNumberFormat; AFormatString: String);
var
ACell: PCell;
begin begin
WriteNumber(GetCell(ARow, ACol), ANumber, AFormat, AFormatString); WriteNumber(GetCell(ARow, ACol), ANumber, AFormat, AFormatString);
end; end;
@ -2118,7 +2112,6 @@ procedure TsWorksheet.WriteDateTime(ACell: PCell; AValue: TDateTime;
AFormat: TsNumberFormat = nfShortDateTime; AFormatStr: String = ''); AFormat: TsNumberFormat = nfShortDateTime; AFormatStr: String = '');
var var
parser: TsNumFormatParser; parser: TsNumFormatParser;
nf: TsNumberFormat;
begin begin
if ACell <> nil then begin if ACell <> nil then begin
ACell^.ContentType := cctDateTime; ACell^.ContentType := cctDateTime;
@ -2512,7 +2505,6 @@ end;
function TsWorksheet.CalcAutoRowHeight(ARow: Cardinal): Single; function TsWorksheet.CalcAutoRowHeight(ARow: Cardinal): Single;
var var
cell: PCell; cell: PCell;
fnt: TsFont;
col: Integer; col: Integer;
h0: Single; h0: Single;
begin begin
@ -2743,7 +2735,8 @@ end;
Returns: True if the file matches any of the known formats, false otherwise Returns: True if the file matches any of the known formats, false otherwise
} }
class function TsWorkbook.GetFormatFromFileName(const AFileName: TFileName; var SheetType: TsSpreadsheetFormat): Boolean; class function TsWorkbook.GetFormatFromFileName(const AFileName: TFileName;
out SheetType: TsSpreadsheetFormat): Boolean;
var var
suffix: String; suffix: String;
begin begin
@ -2863,6 +2856,7 @@ var
SheetType: TsSpreadsheetFormat; SheetType: TsSpreadsheetFormat;
lException: Exception; lException: Exception;
begin begin
SheetType := sfExcel8;
while (SheetType in [sfExcel2..sfExcel8]) and (lException <> nil) do while (SheetType in [sfExcel2..sfExcel8]) and (lException <> nil) do
begin begin
try try
@ -3143,7 +3137,7 @@ end;
} }
procedure TsWorkbook.RemoveAllFonts; procedure TsWorkbook.RemoveAllFonts;
var var
i, n: Integer; i: Integer;
fnt: TsFont; fnt: TsFont;
begin begin
for i:=FFontList.Count-1 downto 0 do begin for i:=FFontList.Count-1 downto 0 do begin
@ -3215,8 +3209,6 @@ end;
The color must in little-endian notation (like TColor of the graphics units) The color must in little-endian notation (like TColor of the graphics units)
} }
function TsWorkbook.AddColorToPalette(AColorValue: TsColorValue): TsColor; function TsWorkbook.AddColorToPalette(AColorValue: TsColorValue): TsColor;
var
i: Integer;
begin begin
// Look look for the color. Is it already in the existing palette? // Look look for the color. Is it already in the existing palette?
if Length(FPalette) > 0 then if Length(FPalette) > 0 then
@ -3427,8 +3419,6 @@ begin
end; end;
function TsCustomNumFormatList.AddFormat(AFormatCell: PCell): Integer; function TsCustomNumFormatList.AddFormat(AFormatCell: PCell): Integer;
var
item: TsNumFormatData;
begin begin
if AFormatCell = nil then if AFormatCell = nil then
raise Exception.Create('TsCustomNumFormat.Add: No nil pointers please'); raise Exception.Create('TsCustomNumFormat.Add: No nil pointers please');
@ -3469,7 +3459,6 @@ var
fmt: String; fmt: String;
lFormatData: TsNumFormatData; lFormatData: TsNumFormatData;
i: Integer; i: Integer;
nf: TsNumberFormat;
begin begin
i := FindByIndex(AFormatIndex); i := FindByIndex(AFormatIndex);
if i > 0 then begin if i > 0 then begin
@ -3478,8 +3467,6 @@ begin
end else end else
fmt := AFormatString; fmt := AFormatString;
nf := nfGeneral;
// Analyzes the format string and tries to convert it to fpSpreadsheet format. // Analyzes the format string and tries to convert it to fpSpreadsheet format.
parser := TsNumFormatParser.Create(Workbook, fmt); //, nf, cdToFPSpreadsheet); parser := TsNumFormatParser.Create(Workbook, fmt); //, nf, cdToFPSpreadsheet);
try try
@ -3512,8 +3499,6 @@ procedure TsCustomNumFormatList.AnalyzeAndAdd(AFormatIndex: Integer;
AFormatString: String); AFormatString: String);
var var
nf: TsNumberFormat; nf: TsNumberFormat;
decs: Byte;
currsym: String;
begin begin
if FindByIndex(AFormatIndex) > -1 then if FindByIndex(AFormatIndex) > -1 then
exit; exit;

View File

@ -13,7 +13,7 @@ unit fpspreadsheetchart;
interface interface
uses uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Grids, Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
// TChart // TChart
{tasources,} TACustomSource, {tasources,} TACustomSource,
// FPSpreadsheet Visual // FPSpreadsheet Visual

View File

@ -117,7 +117,7 @@ type
procedure DrawSelection; procedure DrawSelection;
procedure DrawTextInCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); override; procedure DrawTextInCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
function GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer; function GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
var ABorderStyle: TsCellBorderStyle): Boolean; out ABorderStyle: TsCellBorderStyle): Boolean;
function GetCellHeight(ACol, ARow: Integer): Integer; function GetCellHeight(ACol, ARow: Integer): Integer;
function GetCellText(ACol, ARow: Integer): String; function GetCellText(ACol, ARow: Integer): String;
function GetEditText(ACol, ARow: Integer): String; override; function GetEditText(ACol, ARow: Integer): String; override;
@ -333,7 +333,7 @@ procedure Register;
implementation implementation
uses uses
Types, LCLType, LCLIntf, Math, fpCanvas, GraphUtil, fpsUtils; Types, LCLType, LCLIntf, Math, fpCanvas, fpsUtils;
const const
HOR_ALIGNMENTS: array[haLeft..haRight] of TAlignment = ( HOR_ALIGNMENTS: array[haLeft..haRight] of TAlignment = (
@ -548,7 +548,6 @@ end;
Row/Col coordinates are in worksheet units here! } Row/Col coordinates are in worksheet units here! }
procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal); procedure TsCustomWorksheetGrid.ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
var var
h: Integer;
lRow: PRow; lRow: PRow;
begin begin
if (FWorksheet <> nil) then begin if (FWorksheet <> nil) then begin
@ -860,7 +859,6 @@ end;
procedure TsCustomWorksheetGrid.DrawSelection; procedure TsCustomWorksheetGrid.DrawSelection;
var var
P1, P2: TPoint; P1, P2: TPoint;
selrect: TRect;
begin begin
// Cosmetics at the edges of the grid to avoid spurious rests // Cosmetics at the edges of the grid to avoid spurious rests
P1 := CellRect(Selection.Left, Selection.Top).TopLeft; P1 := CellRect(Selection.Left, Selection.Top).TopLeft;
@ -890,14 +888,7 @@ procedure TsCustomWorksheetGrid.DrawTextInCell(ACol, ARow: Integer; ARect: TRect
AState: TGridDrawState); AState: TGridDrawState);
var var
ts: TTextStyle; ts: TTextStyle;
flags: Cardinal;
txt: String; txt: String;
txtL, txtR: String;
txtRect: TRect;
P: TPoint;
w, h, h0, hline: Integer;
i: Integer;
L: TStrings;
c, r: Integer; c, r: Integer;
wrapped: Boolean; wrapped: Boolean;
horAlign: TsHorAlignment; horAlign: TsHorAlignment;
@ -1204,7 +1195,7 @@ end;
matching color in the palette. } matching color in the palette. }
function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor; function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
procedure ColorToHSL(RGB: TColor; var H, S, L : double); procedure ColorToHSL(RGB: TColor; out H, S, L : double);
// Taken from https://code.google.com/p/thtmlviewer/source/browse/trunk/source/HSLUtils.pas?r=277 // Taken from https://code.google.com/p/thtmlviewer/source/browse/trunk/source/HSLUtils.pas?r=277
// The procedure in GraphUtils is crashing for some colors in Laz < 1.3 // The procedure in GraphUtils is crashing for some colors in Laz < 1.3
var var
@ -1247,8 +1238,6 @@ function TsCustomWorksheetGrid.FindNearestPaletteIndex(AColor: TColor): TsColor;
end; end;
function ColorDistance(color1, color2: TColor): Double; function ColorDistance(color1, color2: TColor): Double;
type
TRGBA = packed record R,G,B,A: Byte end;
var var
H1,S1,L1, H2,S2,L2: Double; H1,S1,L1, H2,S2,L2: Double;
begin begin
@ -1662,7 +1651,7 @@ end;
ADeltaCol and ADeltaRow (one of them must be 0, the other one can only be +/-1). ADeltaCol and ADeltaRow (one of them must be 0, the other one can only be +/-1).
ACol and ARow are in grid units. } ACol and ARow are in grid units. }
function TsCustomWorksheetGrid.GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer; function TsCustomWorksheetGrid.GetBorderStyle(ACol, ARow, ADeltaCol, ADeltaRow: Integer;
var ABorderStyle: TsCellBorderStyle): Boolean; out ABorderStyle: TsCellBorderStyle): Boolean;
var var
cell, neighborcell: PCell; cell, neighborcell: PCell;
border, neighborborder: TsCellBorder; border, neighborborder: TsCellBorder;
@ -1936,13 +1925,11 @@ var
ts: TTextStyle; ts: TTextStyle;
flags: Cardinal; flags: Cardinal;
txt: String; txt: String;
txtL, txtR: String;
txtRect: TRect; txtRect: TRect;
P: TPoint; P: TPoint;
w, h, h0, hline: Integer; w, h, h0, hline: Integer;
i: Integer; i: Integer;
L: TStrings; L: TStrings;
c, r: Integer;
wrapped: Boolean; wrapped: Boolean;
begin begin
wrapped := ATextWrap or (ATextRot = rtStacked); wrapped := ATextWrap or (ATextRot = rtStacked);
@ -2462,7 +2449,6 @@ var
i: Integer; i: Integer;
lCol: PCol; lCol: PCol;
lRow: PRow; lRow: PRow;
fc, fr: Integer;
begin begin
if (FWorksheet = nil) or (FWorksheet.GetCellCount = 0) then begin if (FWorksheet = nil) or (FWorksheet.GetCellCount = 0) then begin
if ShowHeaders then begin if ShowHeaders then begin

View File

@ -46,19 +46,19 @@ function LongRGBToExcelPhysical(const RGB: DWord): DWord;
// Other routines // Other routines
function ParseIntervalString(const AStr: string; function ParseIntervalString(const AStr: string;
var AFirstCellRow, AFirstCellCol, ACount: Integer; out AFirstCellRow, AFirstCellCol, ACount: Integer;
var ADirection: TsSelectionDirection): Boolean; out ADirection: TsSelectionDirection): Boolean;
function ParseCellRangeString(const AStr: string; function ParseCellRangeString(const AStr: string;
var AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer; out AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
var AFlags: TsRelFlags): Boolean; out AFlags: TsRelFlags): Boolean;
function ParseCellString(const AStr: string; function ParseCellString(const AStr: string;
var ACellRow, ACellCol: Integer; var AFlags: TsRelFlags): Boolean; overload; out ACellRow, ACellCol: Integer; out AFlags: TsRelFlags): Boolean; overload;
function ParseCellString(const AStr: string; function ParseCellString(const AStr: string;
var ACellRow, ACellCol: Integer): Boolean; overload; out ACellRow, ACellCol: Integer): Boolean; overload;
function ParseCellRowString(const AStr: string; function ParseCellRowString(const AStr: string;
var AResult: Integer): Boolean; out AResult: Integer): Boolean;
function ParseCellColString(const AStr: string; function ParseCellColString(const AStr: string;
var AResult: Integer): Boolean; out AResult: Integer): Boolean;
function GetColString(AColIndex: Integer): String; function GetColString(AColIndex: Integer): String;
function GetCellString(ARow,ACol: Cardinal; AFlags: TsRelFlags): String; function GetCellString(ARow,ACol: Cardinal; AFlags: TsRelFlags): String;
@ -94,7 +94,7 @@ function MakeShortDateFormat(AShortDateFormat: String): String;
function SpecialDateTimeFormat(ACode: String; function SpecialDateTimeFormat(ACode: String;
const AFormatSettings: TFormatSettings; ForWriting: Boolean): String; const AFormatSettings: TFormatSettings; ForWriting: Boolean): String;
function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt; function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt;
var ALeft, ARight: String): Byte; out ALeft, ARight: String): Byte;
procedure SplitFormatString(const AFormatString: String; out APositivePart, procedure SplitFormatString(const AFormatString: String; out APositivePart,
ANegativePart, AZeroPart: String); ANegativePart, AZeroPart: String);
@ -248,8 +248,8 @@ end;
Parses strings like A5:A10 into an selection interval information Parses strings like A5:A10 into an selection interval information
} }
function ParseIntervalString(const AStr: string; function ParseIntervalString(const AStr: string;
var AFirstCellRow, AFirstCellCol, ACount: Integer; out AFirstCellRow, AFirstCellCol, ACount: Integer;
var ADirection: TsSelectionDirection): Boolean; out ADirection: TsSelectionDirection): Boolean;
var var
//Cells: TStringList; //Cells: TStringList;
LastCellRow, LastCellCol: Integer; LastCellRow, LastCellCol: Integer;
@ -303,8 +303,8 @@ end;
Returns in AFlags also information on relative/absolute cells. Returns in AFlags also information on relative/absolute cells.
} }
function ParseCellRangeString(const AStr: string; function ParseCellRangeString(const AStr: string;
var AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer; out AFirstCellRow, AFirstCellCol, ALastCellRow, ALastCellCol: Integer;
var AFlags: TsRelFlags): Boolean; out AFlags: TsRelFlags): Boolean;
var var
p: Integer; p: Integer;
s: String; s: String;
@ -339,8 +339,8 @@ end;
Example "AMP$200" --> (rel) column 1029 (= 26*26*1 + 26*16 + 26 - 1) Example "AMP$200" --> (rel) column 1029 (= 26*26*1 + 26*16 + 26 - 1)
(abs) row = 199 (abs) (abs) row = 199 (abs)
} }
function ParseCellString(const AStr: String; var ACellRow, ACellCol: Integer; function ParseCellString(const AStr: String; out ACellRow, ACellCol: Integer;
var AFlags: TsRelFlags): Boolean; out AFlags: TsRelFlags): Boolean;
function Scan(AStartPos: Integer): Boolean; function Scan(AStartPos: Integer): Boolean;
const const
@ -410,14 +410,14 @@ end;
{ for compatibility with old version which does not return flags for relative { for compatibility with old version which does not return flags for relative
cell addresses } cell addresses }
function ParseCellString(const AStr: string; function ParseCellString(const AStr: string;
var ACellRow, ACellCol: Integer): Boolean; out ACellRow, ACellCol: Integer): Boolean;
var var
flags: TsRelFlags; flags: TsRelFlags;
begin begin
ParseCellString(AStr, ACellRow, ACellCol, flags); Result := ParseCellString(AStr, ACellRow, ACellCol, flags);
end; end;
function ParseCellRowString(const AStr: string; var AResult: Integer): Boolean; function ParseCellRowString(const AStr: string; out AResult: Integer): Boolean;
begin begin
try try
AResult := StrToInt(AStr) - 1; AResult := StrToInt(AStr) - 1;
@ -427,7 +427,7 @@ begin
Result := True; Result := True;
end; end;
function ParseCellColString(const AStr: string; var AResult: Integer): Boolean; function ParseCellColString(const AStr: string; out AResult: Integer): Boolean;
const const
INT_NUM_LETTERS = 26; INT_NUM_LETTERS = 26;
begin begin
@ -607,8 +607,6 @@ end;
and "msz" (for "mm:ss.z"). } and "msz" (for "mm:ss.z"). }
function BuildDateTimeFormatString(ANumberFormat: TsNumberFormat; function BuildDateTimeFormatString(ANumberFormat: TsNumberFormat;
const AFormatSettings: TFormatSettings; AFormatString: String = '') : string; const AFormatSettings: TFormatSettings; AFormatString: String = '') : string;
var
fmt: String;
begin begin
case ANumberFormat of case ANumberFormat of
nfShortDateTime: nfShortDateTime:
@ -932,7 +930,7 @@ end;
and right part and returns 1 if the format string is in the left, and 2 if and right part and returns 1 if the format string is in the left, and 2 if
it is in the right part. Additionally removes Excel format codes '_' } it is in the right part. Additionally removes Excel format codes '_' }
function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt; function SplitAccountingFormatString(const AFormatString: String; ASection: ShortInt;
var ALeft, ARight: String): Byte; out ALeft, ARight: String): Byte;
var var
P: PChar; P: PChar;
PStart, PEnd: PChar; PStart, PEnd: PChar;

View File

@ -214,6 +214,7 @@ type
procedure TestWriteReadDates_BIFF2; procedure TestWriteReadDates_BIFF2;
procedure TestWriteReadDates_BIFF5; procedure TestWriteReadDates_BIFF5;
procedure TestWriteReadDates_BIFF8; procedure TestWriteReadDates_BIFF8;
procedure TestWriteReadDates_ODS;
end; end;
@ -358,6 +359,11 @@ begin
TestWriteReadDates(sfExcel8); TestWriteReadDates(sfExcel8);
end; end;
procedure TSpreadWriteReadDateTests.TestWriteReadDates_ODS;
begin
TestWriteReadDates(sfOpenDocument);
end;
{ TSpreadReadDateTests } { TSpreadReadDateTests }

View File

@ -150,7 +150,6 @@ var
row, col: Integer; row, col: Integer;
MyCell: PCell; MyCell: PCell;
TempFile: string; //write xls/xml to this file and read back from it TempFile: string; //write xls/xml to this file and read back from it
i: Integer;
L: TStringList; L: TStringList;
s: String; s: String;
begin begin

View File

@ -131,8 +131,6 @@ var
row, col: Integer; row, col: Integer;
MyCell: PCell; MyCell: PCell;
TempFile: string; //write xls/xml to this file and read back from it TempFile: string; //write xls/xml to this file and read back from it
currValue: String;
expectedValue: String;
begin begin
TempFile:=GetTempFileName; TempFile:=GetTempFileName;
{// Not needed: use workbook.writetofile with overwrite=true {// Not needed: use workbook.writetofile with overwrite=true

View File

@ -531,7 +531,6 @@ var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
MyCell: PCell; MyCell: PCell;
ActualColWidth: Single;
col: Integer; col: Integer;
expected: String; expected: String;
current: String; current: String;
@ -611,7 +610,6 @@ var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
MyCell: PCell; MyCell: PCell;
ActualColWidth: Single;
row, col: Integer; row, col: Integer;
b: TsCellBorder; b: TsCellBorder;
expected: Integer; expected: Integer;
@ -788,7 +786,6 @@ var
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
ActualRowHeight: Single; ActualRowHeight: Single;
Row: Integer; Row: Integer;
lpRow: PRow;
TempFile: string; //write xls/xml to this file and read back from it TempFile: string; //write xls/xml to this file and read back from it
begin begin
TempFile:=GetTempFileName; TempFile:=GetTempFileName;
@ -856,7 +853,6 @@ var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
MyCell: PCell; MyCell: PCell;
ActualColWidth: Single;
tr: TsTextRotation; tr: TsTextRotation;
row: Integer; row: Integer;
TempFile: string; //write xls/xml to this file and read back from it TempFile: string; //write xls/xml to this file and read back from it

View File

@ -57,20 +57,16 @@ const
var var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
ActualString: String; Row: Integer;
Row, Col: Integer;
TempFile: string; //write xls/xml to this file and read back from it TempFile: string; //write xls/xml to this file and read back from it
expected: String; expected: String;
actual: String; actual: String;
cell: PCell; cell: PCell;
fs: TFormatSettings;
begin begin
TempFile := GetTempFileName; TempFile := GetTempFileName;
// Create test workbook // Create test workbook
MyWorkbook := TsWorkbook.Create; MyWorkbook := TsWorkbook.Create;
// MyWorkbook.FormatSettings.DecimalSeparator := '.';
// MyWorkbook.FormatSettings.ShortDateFormat := 'yyyy-mm-dd';
MyWorkSheet:= MyWorkBook.AddWorksheet(SHEET); MyWorkSheet:= MyWorkBook.AddWorksheet(SHEET);
// Write out all test formulas // Write out all test formulas

View File

@ -55,7 +55,6 @@ procedure TSpreadInternalTests.GetSheetByIndex;
var var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
Row: Cardinal;
begin begin
MyWorkbook := TsWorkbook.Create; MyWorkbook := TsWorkbook.Create;
MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet); MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet);
@ -71,7 +70,6 @@ const
var var
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
Row: Cardinal;
begin begin
MyWorkbook := TsWorkbook.Create; MyWorkbook := TsWorkbook.Create;
MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet); MyWorkSheet:=MyWorkBook.AddWorksheet(InternalSheet);
@ -128,7 +126,6 @@ procedure TSpreadInternalTests.ReadDateAsUTF8;
var var
ActualDT: TDateTime; ActualDT: TDateTime;
ActualDTString: string; //Result from ReadAsUTF8Text ActualDTString: string; //Result from ReadAsUTF8Text
Cell: PCell;
MyWorksheet: TsWorksheet; MyWorksheet: TsWorksheet;
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;
Row,Column: Cardinal; Row,Column: Cardinal;

View File

@ -66,7 +66,6 @@ type
implementation implementation
uses uses
Math, StrUtils,
fpsUtils, rpnFormulaUnit; fpsUtils, rpnFormulaUnit;
const const

View File

@ -28,7 +28,6 @@ const
SBaseCells = 'Data cells:'; SBaseCells = 'Data cells:';
SHelloWorld = 'Hello world!'; SHelloWorld = 'Hello world!';
var var
Cell: PCell;
Row: Integer; Row: Integer;
value: Double; value: Double;
r,c: integer; r,c: integer;

View File

@ -47,9 +47,6 @@
<UseExternalDbgSyms Value="True"/> <UseExternalDbgSyms Value="True"/>
</Debugging> </Debugging>
</Linking> </Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item2> </Item2>
</BuildModes> </BuildModes>
@ -79,7 +76,6 @@
<Unit0> <Unit0>
<Filename Value="spreadtestgui.lpr"/> <Filename Value="spreadtestgui.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="spreadtestgui"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="datetests.pas"/> <Filename Value="datetests.pas"/>
@ -104,7 +100,6 @@
<Unit5> <Unit5>
<Filename Value="testsutility.pas"/> <Filename Value="testsutility.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="testsutility"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="internaltests.pas"/> <Filename Value="internaltests.pas"/>
@ -129,7 +124,6 @@
<Unit10> <Unit10>
<Filename Value="optiontests.pas"/> <Filename Value="optiontests.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="optiontests"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="numformatparsertests.pas"/> <Filename Value="numformatparsertests.pas"/>
@ -169,9 +163,6 @@
<OptimizationLevel Value="0"/> <OptimizationLevel Value="0"/>
</Optimizations> </Optimizations>
</CodeGeneration> </CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="6"> <Exceptions Count="6">

View File

@ -168,18 +168,21 @@ end;
function TVirtualLayer_Item.GetAttributesHumanReadable: UTF8String; function TVirtualLayer_Item.GetAttributesHumanReadable: UTF8String;
var var
T: UTF8String; T: UTF8String = '';
A: TVirtualLayer_CustomAttributes; A: TVirtualLayer_CustomAttributes;
fs: TFormatSettings;
begin begin
Result := '';
A := Attributes; A := Attributes;
if A=nil then Exit; if A=nil then Exit;
fs := DefaultFormatSettings;
Result := Result+'Regular attributes: '; Result := Result+'Regular attributes: ';
if A.IsReadOnly then T:=T+'Read Only,'; if A.IsReadOnly then T:=T+'Read Only,';
if A.IsHidden then T:=T+'Hidden,'; if A.IsHidden then T:=T+'Hidden,';
if A.IsSystem then T:=T+'System file,'; if A.IsSystem then T:=T+'System file,';
T:=LeftStr(T,Length(T)-1); T:=LeftStr(T,Length(T)-1);
Result:=Result+T+#13+#10; Result:=Result+T+#13+#10;
Result:=Result+'Last modification: '+FormatDateTime(LongDateFormat+' '+LongTimeFormat,A.LastModification)+#13+#10; Result:=Result+'Last modification: '+FormatDateTime(fs.LongDateFormat+' '+fs.LongTimeFormat,A.LastModification)+#13+#10;
end; end;
function TVirtualLayer_Item.GetAttributes: TVirtualLayer_CustomAttributes; function TVirtualLayer_Item.GetAttributes: TVirtualLayer_CustomAttributes;

View File

@ -30,7 +30,7 @@ interface
uses uses
Classes, SysUtils, Classes, SysUtils,
fpimage, fgl, fpimage, fgl,
fpspreadsheet, xlscommon, fpsutils, lconvencoding; fpspreadsheet, fpsutils, lconvencoding;
type type
@ -378,7 +378,6 @@ procedure TsWikiTableWriter.WriteToStrings_WikiMedia(AStrings: TStrings);
var var
i, j: Integer; i, j: Integer;
lCurStr: string = ''; lCurStr: string = '';
lCurCell: PCell;
lCurUsedFormatting: TsUsedFormattingFields; lCurUsedFormatting: TsUsedFormattingFields;
lCurColor: TsColor; lCurColor: TsColor;
lColorStr: String; lColorStr: String;

View File

@ -42,11 +42,11 @@ type
TsBIFF2NumFormatList = class(TsCustomNumFormatList) TsBIFF2NumFormatList = class(TsCustomNumFormatList)
protected protected
procedure AddBuiltinFormats; override; procedure AddBuiltinFormats; override;
public
constructor Create(AWorkbook: TsWorkbook);
procedure ConvertBeforeWriting(var AFormatString: String; procedure ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); override; var ANumFormat: TsNumberFormat); override;
function FindFormatOf(AFormatCell: PCell): Integer; override; function FindFormatOf(AFormatCell: PCell): Integer; override;
public
constructor Create(AWorkbook: TsWorkbook);
end; end;
{ TsSpreadBIFF2Reader } { TsSpreadBIFF2Reader }
@ -56,7 +56,6 @@ type
WorkBookEncoding: TsEncoding; WorkBookEncoding: TsEncoding;
FWorksheet: TsWorksheet; FWorksheet: TsWorksheet;
FFont: TsFont; FFont: TsFont;
FFmtIndex: Integer;
protected protected
procedure ApplyCellFormatting(ARow, ACol: Cardinal; XFIndex: Word); override; procedure ApplyCellFormatting(ARow, ACol: Cardinal; XFIndex: Word); override;
procedure CreateNumFormatList; override; procedure CreateNumFormatList; override;
@ -177,9 +176,10 @@ end;
procedure TsBIFF2NumFormatList.AddBuiltinFormats; procedure TsBIFF2NumFormatList.AddBuiltinFormats;
var var
fs: TFormatSettings; fs: TFormatSettings;
ds, ts, cs: string; cs: string;
begin begin
fs := FWorkbook.FormatSettings; fs := FWorkbook.FormatSettings;
cs := fs.CurrencyString;
AddFormat( 0, '', nfGeneral); AddFormat( 0, '', nfGeneral);
AddFormat( 1, '0', nfFixed); AddFormat( 1, '0', nfFixed);
AddFormat( 2, '0.00', nfFixed); AddFormat( 2, '0.00', nfFixed);
@ -210,7 +210,6 @@ end;
procedure TsBIFF2NumFormatList.ConvertBeforeWriting(var AFormatString: String; procedure TsBIFF2NumFormatList.ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); var ANumFormat: TsNumberFormat);
var var
fmt: String;
parser: TsNumFormatParser; parser: TsNumFormatParser;
begin begin
if AFormatString = '' then if AFormatString = '' then
@ -230,7 +229,6 @@ end;
function TsBIFF2NumFormatList.FindFormatOf(AFormatCell: PCell): Integer; function TsBIFF2NumFormatList.FindFormatOf(AFormatCell: PCell): Integer;
var var
fmt: String;
parser: TsNumFormatParser; parser: TsNumFormatParser;
decs: Integer; decs: Integer;
dt: string; dt: string;
@ -273,7 +271,6 @@ procedure TsSpreadBIFF2Reader.ApplyCellFormatting(ARow, ACol: Cardinal;
var var
lCell: PCell; lCell: PCell;
xfData: TXFListData; xfData: TXFListData;
style: Byte;
begin begin
lCell := FWorksheet.GetCell(ARow, ACol); lCell := FWorksheet.GetCell(ARow, ACol);
@ -467,13 +464,11 @@ var
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: Word; XF: Word;
ok: Boolean; ok: Boolean;
formulaResult: Double; formulaResult: Double = 0.0;
// rpnFormula: TsRPNFormula; // rpnFormula: TsRPNFormula;
Data: array [0..7] of byte; Data: array [0..7] of byte;
dt: TDateTime; dt: TDateTime;
nf: TsNumberFormat; nf: TsNumberFormat;
nd: Byte;
ncs: String;
nfs: String; nfs: String;
err: TsErrorValue; err: TsErrorValue;
cell: PCell; cell: PCell;
@ -573,11 +568,9 @@ procedure TsSpreadBIFF2Reader.ReadNumber(AStream: TStream);
var var
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: Word; XF: Word;
value: Double; value: Double = 0.0;
dt: TDateTime; dt: TDateTime;
nf: TsNumberFormat; nf: TsNumberFormat;
nd: Byte;
ncs: String;
nfs: String; nfs: String;
begin begin
{ BIFF Record row/column/style } { BIFF Record row/column/style }
@ -601,7 +594,7 @@ procedure TsSpreadBIFF2Reader.ReadInteger(AStream: TStream);
var var
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: Word; XF: Word;
AWord : Word; AWord : Word = 0;
begin begin
{ BIFF Record row/column/style } { BIFF Record row/column/style }
ReadRowColXF(AStream, ARow, ACol, XF); ReadRowColXF(AStream, ARow, ACol, XF);
@ -699,12 +692,10 @@ end;
"show sheet headers", "panes are frozen", etc. } "show sheet headers", "panes are frozen", etc. }
procedure TsSpreadBIFF2Reader.ReadWindow2(AStream: TStream); procedure TsSpreadBIFF2Reader.ReadWindow2(AStream: TStream);
var var
b: byte;
w: Word;
rgb: DWord; rgb: DWord;
begin begin
// Show formulas, not results // Show formulas, not results
b := AStream.ReadByte; AStream.ReadByte;
// Show grid lines // Show grid lines
if AStream.ReadByte <> 0 then if AStream.ReadByte <> 0 then
@ -725,16 +716,16 @@ begin
FWorksheet.Options := FWorksheet.Options - [soHasFrozenPanes]; FWorksheet.Options := FWorksheet.Options - [soHasFrozenPanes];
// Show zero values // Show zero values
b := AStream.ReadByte; AStream.ReadByte;
// Index to first visible row // Index to first visible row
w := WordLEToN(AStream.ReadWord); WordLEToN(AStream.ReadWord);
// Indoex to first visible column // Indoex to first visible column
w := WordLEToN(AStream.ReadWord); WordLEToN(AStream.ReadWord);
// Use automatic grid line color (0= manual) // Use automatic grid line color (0= manual)
b := AStream.ReadByte; AStream.ReadByte;
// Manual grid line line color (rgb) // Manual grid line line color (rgb)
rgb := DWordToLE(AStream.ReadDWord); rgb := DWordToLE(AStream.ReadDWord);
@ -869,8 +860,6 @@ procedure TsSpreadBIFF2Writer.WriteCellFormatting(AStream: TStream; ACell: PCell
XFIndex: Word); XFIndex: Word);
var var
b: Byte; b: Byte;
xf: Word;
i: Integer;
begin begin
if ACell^.UsedFormattingFields = [] then if ACell^.UsedFormattingFields = [] then
begin begin
@ -1096,7 +1085,6 @@ var
lBorders: TsCellBorders; lBorders: TsCellBorders;
lAddBackground: Boolean; lAddBackground: Boolean;
lHorAlign: TsHorAlignment; lHorAlign: TsHorAlignment;
fmt: String;
begin begin
// The loop starts with the first style added manually. // The loop starts with the first style added manually.
// First style was already added (see AddDefaultFormats) // First style was already added (see AddDefaultFormats)

View File

@ -1022,9 +1022,6 @@ var
optns: Word; optns: Word;
b: Byte; b: Byte;
dw1, dw2: DWord; dw1, dw2: DWord;
XFOptions: Word;
XFAlignment: byte;
XFBorderDWord1, XFBorderDWord2: DWord;
begin begin
{ BIFF Record header } { BIFF Record header }
AStream.WriteWord(WordToLE(INT_EXCEL_ID_XF)); AStream.WriteWord(WordToLE(INT_EXCEL_ID_XF));
@ -1098,7 +1095,6 @@ var
lHorAlign: TsHorAlignment; lHorAlign: TsHorAlignment;
lVertAlign: TsVertAlignment; lVertAlign: TsVertAlignment;
lWordWrap: Boolean; lWordWrap: Boolean;
fmt: String;
begin begin
// The first style was already added // The first style was already added
for i := 1 to Length(FFormattingStyles) - 1 do begin for i := 1 to Length(FFormattingStyles) - 1 do begin

View File

@ -85,10 +85,10 @@ type
procedure ReadLabelSST(const AStream: TStream); procedure ReadLabelSST(const AStream: TStream);
// procedure ReadNumber() --> xlscommon // procedure ReadNumber() --> xlscommon
procedure ReadRichString(const AStream: TStream); procedure ReadRichString(const AStream: TStream);
procedure ReadRPNCellAddress(AStream: TStream; var ARow, ACol: Cardinal; procedure ReadRPNCellAddress(AStream: TStream; out ARow, ACol: Cardinal;
var AFlags: TsRelFlags); override; out AFlags: TsRelFlags); override;
procedure ReadRPNCellRangeAddress(AStream: TStream; procedure ReadRPNCellRangeAddress(AStream: TStream;
var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); override; out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags); override;
procedure ReadSST(const AStream: TStream); procedure ReadSST(const AStream: TStream);
function ReadString_8bitLen(AStream: TStream): String; override; function ReadString_8bitLen(AStream: TStream): String; override;
procedure ReadStringRecord(AStream: TStream); override; procedure ReadStringRecord(AStream: TStream); override;
@ -294,7 +294,6 @@ var
lHorAlign: TsHorAlignment; lHorAlign: TsHorAlignment;
lVertAlign: TsVertAlignment; lVertAlign: TsVertAlignment;
lWordWrap: Boolean; lWordWrap: Boolean;
fmt: String;
begin begin
// The first style was already added --> begin loop with 1 // The first style was already added --> begin loop with 1
for i := 1 to Length(FFormattingStyles) - 1 do begin for i := 1 to Length(FFormattingStyles) - 1 do begin
@ -389,12 +388,10 @@ procedure TsSpreadBIFF8Writer.WriteToStream(AStream: TStream);
const const
isBIFF8 = true; isBIFF8 = true;
var var
MyData: TMemoryStream;
CurrentPos: Int64; CurrentPos: Int64;
Boundsheets: array of Int64; Boundsheets: array of Int64;
sheet: TsWorksheet; sheet: TsWorksheet;
i, j, len: Integer; i, len: Integer;
col: PCol;
begin begin
{ Write workbook globals } { Write workbook globals }
@ -1382,7 +1379,6 @@ function TsSpreadBIFF8Reader.ReadWideString(const AStream: TStream;
const AUse8BitLength: Boolean): WideString; const AUse8BitLength: Boolean): WideString;
var var
Len: Word; Len: Word;
WideName: WideString;
begin begin
if AUse8BitLength then if AUse8BitLength then
Len := AStream.ReadByte() Len := AStream.ReadByte()
@ -1606,11 +1602,9 @@ end;
procedure TsSpreadBIFF8Reader.ReadLabel(AStream: TStream); procedure TsSpreadBIFF8Reader.ReadLabel(AStream: TStream);
var var
L: Word; L: Word;
StringFlags: BYTE;
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: Word; XF: Word;
WideStrValue: WideString; WideStrValue: WideString;
AnsiStrValue: AnsiString;
begin begin
{ BIFF Record data: Row, Column, XF Index } { BIFF Record data: Row, Column, XF Index }
ReadRowColXF(AStream, ARow, ACol, XF); ReadRowColXF(AStream, ARow, ACol, XF);
@ -1659,7 +1653,7 @@ end;
bits to distinguish between absolute and relative addresses. bits to distinguish between absolute and relative addresses.
Overriding the implementation in xlscommon. } Overriding the implementation in xlscommon. }
procedure TsSpreadBIFF8Reader.ReadRPNCellAddress(AStream: TStream; procedure TsSpreadBIFF8Reader.ReadRPNCellAddress(AStream: TStream;
var ARow, ACol: Cardinal; var AFlags: TsRelFlags); out ARow, ACol: Cardinal; out AFlags: TsRelFlags);
var var
c: word; c: word;
begin begin
@ -1680,7 +1674,7 @@ end;
relative addresses. relative addresses.
Overriding the implementation in xlscommon. } Overriding the implementation in xlscommon. }
procedure TsSpreadBIFF8Reader.ReadRPNCellRangeAddress(AStream: TStream; procedure TsSpreadBIFF8Reader.ReadRPNCellRangeAddress(AStream: TStream;
var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags);
var var
c1, c2: word; c1, c2: word;
begin begin
@ -1922,7 +1916,6 @@ var
lColor: Word; lColor: Word;
lWeight: Word; lWeight: Word;
Len: Byte; Len: Byte;
lFontName: UTF8String;
font: TsFont; font: TsFont;
begin begin
font := TsFont.Create; font := TsFont.Create;

View File

@ -357,9 +357,9 @@ type
TsBIFFNumFormatList = class(TsCustomNumFormatList) TsBIFFNumFormatList = class(TsCustomNumFormatList)
protected protected
procedure AddBuiltinFormats; override; procedure AddBuiltinFormats; override;
public
procedure ConvertBeforeWriting(var AFormatString: String; procedure ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); override; var ANumFormat: TsNumberFormat); override;
public
end; end;
{ TsSpreadBIFFReader } { TsSpreadBIFFReader }
@ -385,7 +385,7 @@ type
function FindNumFormatDataForCell(const AXFIndex: Integer): TsNumFormatData; function FindNumFormatDataForCell(const AXFIndex: Integer): TsNumFormatData;
// Tries to find if a number cell is actually a date/datetime/time cell and retrieves the value // Tries to find if a number cell is actually a date/datetime/time cell and retrieves the value
function IsDateTime(Number: Double; ANumberFormat: TsNumberFormat; function IsDateTime(Number: Double; ANumberFormat: TsNumberFormat;
ANumberFormatStr: String; var ADateTime: TDateTime): Boolean; ANumberFormatStr: String; out ADateTime: TDateTime): Boolean;
// Here we can add reading of records which didn't change across BIFF5-8 versions // Here we can add reading of records which didn't change across BIFF5-8 versions
procedure ReadCodePage(AStream: TStream); procedure ReadCodePage(AStream: TStream);
// Read column info // Read column info
@ -413,10 +413,10 @@ type
// Read row info // Read row info
procedure ReadRowInfo(AStream: TStream); virtual; procedure ReadRowInfo(AStream: TStream); virtual;
// Read the array of RPN tokens of a formula // Read the array of RPN tokens of a formula
procedure ReadRPNCellAddress(AStream: TStream; var ARow, ACol: Cardinal; procedure ReadRPNCellAddress(AStream: TStream; out ARow, ACol: Cardinal;
var AFlags: TsRelFlags); virtual; out AFlags: TsRelFlags); virtual;
procedure ReadRPNCellRangeAddress(AStream: TStream; procedure ReadRPNCellRangeAddress(AStream: TStream;
var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); virtual; out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags); virtual;
function ReadRPNFunc(AStream: TStream): Word; virtual; function ReadRPNFunc(AStream: TStream): Word; virtual;
function ReadRPNTokenArray(AStream: TStream; var AFormula: TsRPNFormula): Boolean; function ReadRPNTokenArray(AStream: TStream; var AFormula: TsRPNFormula): Boolean;
function ReadRPNTokenArraySize(AStream: TStream): word; virtual; function ReadRPNTokenArraySize(AStream: TStream): word; virtual;
@ -437,8 +437,8 @@ type
TsSpreadBIFFWriter = class(TsCustomSpreadWriter) TsSpreadBIFFWriter = class(TsCustomSpreadWriter)
protected protected
FDateMode: TDateMode; FDateMode: TDateMode;
FLastRow: Integer; FLastRow: Cardinal;
FLastCol: Word; FLastCol: Cardinal;
procedure AddDefaultFormats; override; procedure AddDefaultFormats; override;
procedure CreateNumFormatList; override; procedure CreateNumFormatList; override;
procedure GetLastRowCallback(ACell: PCell; AStream: TStream); procedure GetLastRowCallback(ACell: PCell; AStream: TStream);
@ -494,7 +494,7 @@ type
implementation implementation
uses uses
StrUtils, fpsNumFormatParser; fpsNumFormatParser;
{ Helper table for rpn formulas: { Helper table for rpn formulas:
Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. } Assignment of FormulaElementKinds (fekXXXX) to EXCEL_TOKEN IDs. }
@ -762,7 +762,6 @@ procedure TsBIFFNumFormatList.ConvertBeforeWriting(var AFormatString: String;
var ANumFormat: TsNumberFormat); var ANumFormat: TsNumberFormat);
var var
parser: TsNumFormatParser; parser: TsNumFormatParser;
fmt: String;
begin begin
parser := TsNumFormatParser.Create(Workbook, AFormatString, ANumFormat); parser := TsNumFormatParser.Create(Workbook, AFormatString, ANumFormat);
try try
@ -852,9 +851,6 @@ end;
formats. formats.
Valid for BIFF5.BIFF8. Needs to be overridden for BIFF2. } Valid for BIFF5.BIFF8. Needs to be overridden for BIFF2. }
procedure TsSpreadBIFFReader.CreateNumFormatList; procedure TsSpreadBIFFReader.CreateNumFormatList;
var
i: Integer;
item: TsNumFormatData;
begin begin
FreeAndNil(FNumFormatList); FreeAndNil(FNumFormatList);
FNumFormatList := TsBIFFNumFormatList.Create(Workbook); FNumFormatList := TsBIFFNumFormatList.Create(Workbook);
@ -927,7 +923,7 @@ end;
{ Convert the number to a date/time and return that if it is } { Convert the number to a date/time and return that if it is }
function TsSpreadBIFFReader.IsDateTime(Number: Double; function TsSpreadBIFFReader.IsDateTime(Number: Double;
ANumberFormat: TsNumberFormat; ANumberFormatStr: String; ANumberFormat: TsNumberFormat; ANumberFormatStr: String;
var ADateTime: TDateTime): boolean; out ADateTime: TDateTime): boolean;
var var
parser: TsNumFormatParser; parser: TsNumFormatParser;
begin begin
@ -1064,16 +1060,12 @@ procedure TsSpreadBIFFReader.ReadFormula(AStream: TStream);
var var
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: WORD; XF: WORD;
ResultFormula: Double; ResultFormula: Double = 0.0;
Data: array [0..7] of byte; Data: array [0..7] of byte;
Flags: WORD; Flags: WORD;
i: Integer;
dt: TDateTime; dt: TDateTime;
nf: TsNumberFormat; nf: TsNumberFormat;
nd: Byte;
ncs: String;
nfs: String; nfs: String;
resultStr: String;
err: TsErrorValue; err: TsErrorValue;
ok: Boolean; ok: Boolean;
cell: PCell; cell: PCell;
@ -1178,9 +1170,7 @@ var
pending: integer; pending: integer;
RK: DWORD; RK: DWORD;
nf: TsNumberFormat; nf: TsNumberFormat;
nd: Byte;
nfs: String; nfs: String;
ncs: String;
begin begin
ARow := WordLEtoN(AStream.ReadWord); ARow := WordLEtoN(AStream.ReadWord);
fc := WordLEtoN(AStream.ReadWord); fc := WordLEtoN(AStream.ReadWord);
@ -1213,12 +1203,10 @@ procedure TsSpreadBIFFReader.ReadNumber(AStream: TStream);
var var
ARow, ACol: Cardinal; ARow, ACol: Cardinal;
XF: WORD; XF: WORD;
value: Double; value: Double = 0.0;
dt: TDateTime; dt: TDateTime;
nf: TsNumberFormat; nf: TsNumberFormat;
nd: Byte;
nfs: String; nfs: String;
ncs: String;
begin begin
ReadRowColXF(AStream, ARow, ACol, XF); ReadRowColXF(AStream, ARow, ACol, XF);
@ -1370,7 +1358,7 @@ end;
bits to distinguish between absolute and relative addresses. bits to distinguish between absolute and relative addresses.
Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. } Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. }
procedure TsSpreadBIFFReader.ReadRPNCellAddress(AStream: TStream; procedure TsSpreadBIFFReader.ReadRPNCellAddress(AStream: TStream;
var ARow, ACol: Cardinal; var AFlags: TsRelFlags); out ARow, ACol: Cardinal; out AFlags: TsRelFlags);
var var
r: word; r: word;
begin begin
@ -1390,7 +1378,7 @@ end;
bits to distinguish between absolute and relative addresses. bits to distinguish between absolute and relative addresses.
Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. } Implemented here for BIFF2-BIFF5. BIFF8 must be overridden. }
procedure TsSpreadBIFFReader.ReadRPNCellRangeAddress(AStream: TStream; procedure TsSpreadBIFFReader.ReadRPNCellRangeAddress(AStream: TStream;
var ARow1, ACol1, ARow2, ACol2: Cardinal; var AFlags: TsRelFlags); out ARow1, ACol1, ARow2, ACol2: Cardinal; out AFlags: TsRelFlags);
var var
r1, r2: word; r1, r2: word;
begin begin
@ -1426,8 +1414,7 @@ var
token: Byte; token: Byte;
rpnItem: PRPNItem; rpnItem: PRPNItem;
supported: boolean; supported: boolean;
wordVal: Word; // 2 byte unsigned integer dblVal: Double = 0.0; // IEEE 8 byte floating point number
dblVal: Double; // IEEE 8 byte floating point number
flags: TsRelFlags; flags: TsRelFlags;
r, c, r2, c2: Cardinal; r, c, r2, c2: Cardinal;
fek: TFEKind; fek: TFEKind;