fpspreadsheet: Fix sudden fails of test suite (Why did these test cases work earlier?)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6465 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2018-06-05 09:33:29 +00:00
parent f4154f2265
commit 4517d6fc12
4 changed files with 16 additions and 52 deletions

View File

@ -912,7 +912,8 @@ type
reading and writing. Lowest memory consumptions, reading and writing. Lowest memory consumptions,
but slow. but slow.
@param boAutoCalc Automatically recalculate formulas whenever a @param boAutoCalc Automatically recalculate formulas whenever a
cell value changes. cell value changes, in particular when file is
loaded.
@param boCalcBeforeSaving Calculates formulas before saving the file. @param boCalcBeforeSaving Calculates formulas before saving the file.
Otherwise there are no results when the file is Otherwise there are no results when the file is
loaded back by fpspreadsheet. loaded back by fpspreadsheet.

View File

@ -118,6 +118,7 @@ begin
try try
MyWorkbook.Options := MyWorkbook.Options + [boReadFormulas]; MyWorkbook.Options := MyWorkbook.Options + [boReadFormulas];
MyWorkbook.ReadFromFile(TempFile, AFormat); MyWorkbook.ReadFromFile(TempFile, AFormat);
MyWorkbook.CalcFormulas;
if AFormat in [sfExcel2, sfCSV] then if AFormat in [sfExcel2, sfCSV] then
MyWorksheet := MyWorkbook.GetFirstWorksheet // only 1 sheet for BIFF2 MyWorksheet := MyWorkbook.GetFirstWorksheet // only 1 sheet for BIFF2
else else

View File

@ -399,6 +399,7 @@ begin
try try
MyWorkbook.Options := Myworkbook.Options + [boReadFormulas]; MyWorkbook.Options := Myworkbook.Options + [boReadFormulas];
MyWorkbook.ReadFromFile(TempFile, AFormat); MyWorkbook.ReadFromFile(TempFile, AFormat);
MyWorkbook.CalcFormulas;
if AFormat = sfExcel2 then if AFormat = sfExcel2 then
MyWorksheet := MyWorkbook.GetFirstWorksheet MyWorksheet := MyWorkbook.GetFirstWorksheet
else else
@ -735,7 +736,7 @@ begin
try try
workbook.Options := workbook.Options + [boReadFormulas]; workbook.Options := workbook.Options + [boReadFormulas];
workbook.ReadFromFile(TempFile, AFormat); workbook.ReadFromFile(TempFile, AFormat);
// workbook.CalcFormulas; workbook.CalcFormulas;
if AFormat = sfExcel2 then if AFormat = sfExcel2 then
Fail('This test should not be executed') Fail('This test should not be executed')

View File

@ -223,9 +223,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteErrorValue(Row, 2, errDivideByZero); MyWorksheet.WriteErrorValue(Row, 2, errDivideByZero);
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errDivideByZero); sollValues[Row] := ErrorResult(errDivideByZero);
// Division of cell values // Division of cell values
@ -1009,9 +1006,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteErrorValue(Row, 2, errOverflow);; MyWorksheet.WriteErrorValue(Row, 2, errOverflow);;
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverFlow); sollValues[Row] := ErrorResult(errOverFlow);
// ARCCOSH - valid result // ARCCOSH - valid result
@ -1044,9 +1038,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteErrorValue(Row, 2, errOverflow); MyWorksheet.WriteErrorValue(Row, 2, errOverflow);
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
if AFormat = sfExcel2 then if AFormat = sfExcel2 then
sollValues[Row] := ErrorResult(errFormulaNotSupported) sollValues[Row] := ErrorResult(errFormulaNotSupported)
else else
@ -1079,9 +1070,6 @@
Myworksheet.WriteFormula(Row, 1, formula); Myworksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteErrorValue(Row, 2, errOverflow); MyWorksheet.WriteErrorValue(Row, 2, errOverflow);
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverFlow); sollValues[Row] := ErrorResult(errOverFlow);
// ARCSINH // ARCSINH
@ -1147,9 +1135,6 @@
myWorksheet.WriteFormula(Row, 1, formula); myWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteErrorValue(Row, 2, errOverFlow); MyWorksheet.WriteErrorValue(Row, 2, errOverFlow);
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
if AFormat = sfExcel2 then if AFormat = sfExcel2 then
sollValues[Row] := ErrorResult(errFormulaNotSupported) sollValues[Row] := ErrorResult(errFormulaNotSupported)
else else
@ -1344,9 +1329,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
myWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); myWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LN - error due to argument < 0 // LN - error due to argument < 0
@ -1361,9 +1343,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG10 - valid result // LOG10 - valid result
@ -1393,9 +1372,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
myWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); myWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG10 - error due to argument < 0 // LOG10 - error due to argument < 0
@ -1410,9 +1386,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverFlow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverFlow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG - valid result (2 arguments) // LOG - valid result (2 arguments)
@ -1444,9 +1417,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG - valid result (1 argument) // LOG - valid result (1 argument)
@ -1477,9 +1447,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG - negative value // LOG - negative value
@ -1495,9 +1462,6 @@
MyWorksheet.WriteFormula(Row, 1, formula); MyWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// LOG of cell // LOG of cell
@ -1746,9 +1710,6 @@
myWorksheet.WriteFormula(Row, 1, formula); myWorksheet.WriteFormula(Row, 1, formula);
MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow)); MyWorksheet.WriteText(Row, 2, GetErrorValueStr(errOverflow));
SetLength(sollValues, Row+1); SetLength(sollValues, Row+1);
if AFormat = sfOpenDocument then
sollValues[Row] := FloatResult(0)
else
sollValues[Row] := ErrorResult(errOverflow); sollValues[Row] := ErrorResult(errOverflow);
// SQRT of cell value // SQRT of cell value