fpspreadsheet: Remove workbook property ReadFormulas, use option boReadFormulas instead. Update all demos affected. Modify most demos to no longer require the fps package.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3505 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2014-08-29 15:32:43 +00:00
parent 6fa634e0a2
commit a043b77519
26 changed files with 120 additions and 73 deletions

View File

@ -27,13 +27,10 @@
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LazUtils"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
@ -46,7 +43,6 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="main"/>
</Unit1>
</Units>
</ProjectOptions>

View File

@ -32,31 +32,35 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="excel2read.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="excel2read"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="excel2read"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,7 +10,7 @@ program excel2read;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, xlsbiff2, laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, xlsbiff2;
var
MyWorkbook: TsWorkbook;

View File

@ -32,7 +32,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -45,14 +45,22 @@
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="excel2write"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,7 +10,7 @@ program excel2write;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, xlsbiff2, laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, xlsbiff2;
var
MyWorkbook: TsWorkbook;

View File

@ -32,31 +32,35 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="excel5read.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="excel5read"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="excel5read"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,8 +10,7 @@ program excel5read;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, xlsbiff5,
laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, xlsbiff5;
var
MyWorkbook: TsWorkbook;

View File

@ -32,31 +32,35 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="excel5write.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="excel5write"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="excel5write"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -36,7 +36,7 @@ begin
// Create the spreadsheet
MyWorkbook := TsWorkbook.Create;
MyWorkbook.ReadFormulas := true;
MyWorkbook.Options := MyWorkbook.Options + [boReadFormulas, boAutoCalc];
MyWorkbook.ReadFromFile(InputFilename, sfExcel8);

View File

@ -32,7 +32,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -45,14 +45,22 @@
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="ooxmlwrite"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,7 +10,7 @@ program ooxmlwrite;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, fpsallformats, laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, fpsallformats;
var
MyWorkbook: TsWorkbook;

View File

@ -32,7 +32,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -51,12 +51,16 @@
<SearchPaths>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
<SrcPath Value=".."/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -11,8 +11,7 @@ program opendocread;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, fpsallformats,
laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, fpsallformats;
var
MyWorkbook: TsWorkbook;

View File

@ -32,7 +32,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -45,14 +45,22 @@
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="opendocwrite"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,8 +10,7 @@ program opendocwrite;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, fpsallformats,
laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, fpsallformats;
var
MyWorkbook: TsWorkbook;

View File

@ -317,7 +317,7 @@ var
begin
workbook := TsWorkbook.Create;
try
workbook.ReadFormulas := true;
workbook.Options := workbook.Options + [boReadFormulas];
workbook.ReadFromFile(AFilename, sfExcel8);
worksheet := workbook.GetFirstWorksheet;

View File

@ -31,7 +31,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -44,13 +44,23 @@
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="wikitableread"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -11,7 +11,7 @@ program wikitableread;
uses
Classes, SysUtils, fpspreadsheet, wikitable,
laz_fpspreadsheet, fpsutils;
fpsutils;
var
MyWorkbook: TsWorkbook;

View File

@ -32,7 +32,7 @@
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>
<PackageName Value="LazUtils"/>
</Item1>
</RequiredPackages>
<Units Count="1">
@ -45,14 +45,22 @@
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="wikitablewrite"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value=".."/>
<SrcPath Value=".."/>
<OtherUnitFiles Value="..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</CONFIG>

View File

@ -10,8 +10,7 @@ program wikitablewrite;
{$mode delphi}{$H+}
uses
Classes, SysUtils, fpspreadsheet, wikitable,
laz_fpspreadsheet;
Classes, SysUtils, fpspreadsheet, wikitable;
const
Str_First = 'First';

View File

@ -764,8 +764,13 @@ type
a cell value changes.
@param boCalcBeforeSaving Calculates formulas before saving the file.
Otherwise there are no results when the file is
loaded back by fpspreadsheet. }
TsWorkbookOption = (boVirtualMode, boBufStream, boAutoCalc, boCalcBeforeSaving);
loaded back by fpspreadsheet.
@param boReadFormulas Allows to turn on/off reading of formulas; this
is a precaution since formulas not or not fully
implemented by fpspreadsheet could crash the
reading operation. }
TsWorkbookOption = (boVirtualMode, boBufStream,
boAutoCalc, boCalcBeforeSaving, boReadFormulas);
{@@
Set of options flags for the workbook }
@ -797,7 +802,6 @@ type
FFontList: TFPList;
FBuiltinFontCount: Integer;
FPalette: array of TsColorValue;
FReadFormulas: Boolean;
FDefaultColWidth: Single; // in "characters". Excel uses the width of char "0" in 1st font
FDefaultRowHeight: Single; // in "character heights", i.e. line count
FVirtualColCount: Cardinal;
@ -905,10 +909,6 @@ type
property FileName: String read FFileName;
{@@ Identifies the file format which was detected when reading the file }
property FileFormat: TsSpreadsheetFormat read FFormat;
{@@ This property allows to turn off reading of rpn formulas; this is a
precaution since formulas not correctly implemented by fpspreadsheet
could crash the reading operation. }
property ReadFormulas: Boolean read FReadFormulas write FReadFormulas;
property VirtualColCount: cardinal read FVirtualColCount write SetVirtualColCount;
property VirtualRowCount: cardinal read FVirtualRowCount write SetVirtualRowCount;
property Options: TsWorkbookOptions read FOptions write FOptions;

View File

@ -923,7 +923,10 @@ procedure TsCustomWorksheetGrid.CreateNewWorkbook;
begin
FreeAndNil(FWorkbook);
FWorkbook := TsWorkbook.Create;
FWorkbook.ReadFormulas := FReadFormulas;
if FReadFormulas then
FWorkbook.Options := FWorkbook.Options + [boReadFormulas]
else
FWorkbook.Options := FWorkbook.Options - [boReadFormulas];
SetAutoCalc(FAutoCalc);
end;

View File

@ -101,7 +101,7 @@ begin
// Open the spreadsheet
MyWorkbook := TsWorkbook.Create;
try
MyWorkbook.ReadFormulas := true;
MyWorkbook.Options := MyWorkbook.Options + [boReadFormulas];
MyWorkbook.ReadFromFile(TempFile, AFormat);
if AFormat = sfExcel2 then

View File

@ -56,7 +56,6 @@
<Unit3>
<Filename Value="numberstests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="numberstests"/>
</Unit3>
<Unit4>
<Filename Value="manualtests.pas"/>
@ -65,7 +64,6 @@
<Unit5>
<Filename Value="testsutility.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testsutility"/>
</Unit5>
<Unit6>
<Filename Value="internaltests.pas"/>
@ -74,7 +72,6 @@
<Unit7>
<Filename Value="formattests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="formattests"/>
</Unit7>
<Unit8>
<Filename Value="colortests.pas"/>
@ -106,17 +103,14 @@
<Unit14>
<Filename Value="emptycelltests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="emptycelltests"/>
</Unit14>
<Unit15>
<Filename Value="errortests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="errortests"/>
</Unit15>
<Unit16>
<Filename Value="virtualmodetests.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="virtualmodetests"/>
</Unit16>
</Units>
</ProjectOptions>

View File

@ -605,7 +605,7 @@ begin
end;
{ Formula token array }
if FWorkbook.ReadFormulas then begin
if boReadFormulas in FWorkbook.Options then begin
ok := ReadRPNTokenArray(AStream, cell);
if not ok then FWorksheet.WriteErrorValue(cell, errFormulaNotSupported);
end;

View File

@ -1251,7 +1251,7 @@ begin
end;
{ Formula token array }
if FWorkbook.ReadFormulas then begin
if boReadFormulas in FWorkbook.Options then begin
ok := ReadRPNTokenArray(AStream, cell);
if not ok then
FWorksheet.WriteErrorValue(cell, errFormulaNotSupported);