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

View File

@ -4,7 +4,7 @@ object Form1: TForm1
Top = 248
Width = 884
Caption = 'fpsGrid'
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

@ -6,7 +6,7 @@ interface
uses
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;
type
@ -873,7 +873,6 @@ var
cell: PCell;
r,c: Cardinal;
found: Boolean;
t: Integer;
begin
with WorksheetGrid do begin
r := GetWorksheetRow(Row);
@ -885,7 +884,6 @@ begin
nf := cell^.NumberFormat;
for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]);
t := ac.Tag;
if (ac.Tag >= NUMFMT_TAG) and (ac.Tag < NUMFMT_TAG + 200) then begin
found := ((ac.Tag - NUMFMT_TAG) div 10 = ord(nf));
if nf = nfCustom then
@ -921,12 +919,10 @@ var
i: Integer;
ac: TAction;
vert_align: TsVertAlignment;
t: Integer;
begin
with WorksheetGrid do vert_align := VertAlignments[Selection];
for i:=0 to ActionList.ActionCount-1 do begin
ac := TAction(ActionList.Actions[i]);
t := ac.tag;
if (ac.Tag >= VERTALIGN_TAG) and (ac.Tag < VERTALIGN_TAG+10) then
ac.Checked := ((ac.Tag - VERTALIGN_TAG) = ord(vert_align));
end;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -168,18 +168,21 @@ end;
function TVirtualLayer_Item.GetAttributesHumanReadable: UTF8String;
var
T: UTF8String;
T: UTF8String = '';
A: TVirtualLayer_CustomAttributes;
fs: TFormatSettings;
begin
A:=Attributes;
Result := '';
A := Attributes;
if A=nil then Exit;
Result:=Result+'Regular attributes: ';
fs := DefaultFormatSettings;
Result := Result+'Regular attributes: ';
if A.IsReadOnly then T:=T+'Read Only,';
if A.IsHidden then T:=T+'Hidden,';
if A.IsSystem then T:=T+'System file,';
T:=LeftStr(T,Length(T)-1);
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;
function TVirtualLayer_Item.GetAttributes: TVirtualLayer_CustomAttributes;

View File

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

View File

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

View File

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

View File

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

View File

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