fpspreadsheet: Fix reading of ods files containing formulas with several arguments (separator semicolon). Update unit tests. (Still issues with files posted at https://forum.lazarus.freepascal.org/index.php/topic,42168.msg293792.html).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6574 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-09 14:28:17 +00:00
parent a3d2a3ae8d
commit 6e2cc3fe7e
8 changed files with 182 additions and 111 deletions

View File

@@ -83,6 +83,10 @@ type
procedure SumMultiSheetRange_FlippedSheetsAndCells_OOXML;
procedure SumMultiSheetRange_FlippedSheetsAndCells_ODS;
procedure IfConst_BIFF8;
procedure IfConst_OOXML;
procedure IfConst_ODS;
procedure CountIfRange_BIFF8;
procedure CountIfRangeSheet_BIFF8;
@@ -335,7 +339,7 @@ procedure TSpreadSingleFormulaTests.YearConst_BIFF8;
var
s: String;
begin
s := FormatDateTime(ExprFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), ExprFormatSettings);
s := FormatDateTime(DefaultFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), ExprFormatSettings);
TestFormula(Format('YEAR("%s")', [s]), '2012', ftkConstants, sfExcel8);
end;
@@ -348,7 +352,7 @@ procedure TSpreadSingleFormulaTests.MonthConst_BIFF8;
var
s: String;
begin
s := FormatDateTime(ExprFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), ExprFormatSettings);
s := FormatDateTime(DefaultFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), DefaultFormatSettings);
TestFormula(Format('MONTH("%s")', [s]), '2', ftkConstants, sfExcel8);
end;
@@ -361,7 +365,7 @@ procedure TSpreadSingleFormulaTests.DayConst_BIFF8;
var
s: String;
begin
s := FormatDateTime(ExprFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), ExprFormatSettings);
s := FormatDateTime(DefaultFormatSettings.ShortDateFormat, EncodeDate(2012,2,5), DefaultFormatSettings);
TestFormula(Format('DAY("%s")', [s]), '5', ftkConstants, sfExcel8);
end;
@@ -376,7 +380,7 @@ procedure TSpreadSingleFormulaTests.HourConst_BIFF8;
var
s: String;
begin
s := FormatDateTime(ExprFormatSettings.LongTimeFormat, EncodeTime(14, 20, 41, 0), ExprFormatSettings);
s := FormatDateTime(ExprFormatSettings.LongTimeFormat, EncodeTime(14, 20, 41, 0), DefaultFormatSettings);
TestFormula(Format('HOUR("%s")', [s]), '14', ftkConstants, sfExcel8);
end;
@@ -515,6 +519,23 @@ end;
{ --- }
procedure TSpreadSingleFormulaTests.IfConst_BIFF8;
begin
TestFormula('IF(C3="A","is A","not A")', 'is A', ftkConstants, sfExcel8);
end;
procedure TSpreadSingleFormulaTests.IfConst_OOXML;
begin
TestFormula('IF(C3="A","is A","not A")', 'is A', ftkConstants, sfOOXML);
end;
procedure TSpreadSingleFormulaTests.IfConst_ODS;
begin
TestFormula('IF(C3="A","is A","not A")', 'is A', ftkConstants, sfOpenDocument);
end;
{ --- }
procedure TSpreadSingleFormulaTests.CountIfRange_BIFF8;
begin
TestFormula('COUNTIF(C3:C5,">1")', '1', ftkCellRange, sfExcel8);

View File

@@ -17,7 +17,6 @@
{------------------------------------------------------------------------------}
// Addition
Row := 0;
formula := '1+1';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -1874,7 +1873,7 @@
// DAY / argument string
inc(Row);
s := DateToStr(EncodeDate(2014, 7, 1)); // Localization of the test
s := DateToStr(EncodeDate(2014, 7, 1), ExprFormatSettings); // Localization of the test
formula := 'DAY("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -1906,7 +1905,7 @@
// HOUR / argument string
inc(Row);
s := TimeToStr(EncodeTime(9, 59, 20, 0)); // Localization of the test
s := TimeToStr(EncodeTime(9, 59, 20, 0), ExprFormatSettings); // Localization of the test
formula := 'HOUR("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -1938,7 +1937,7 @@
// MINUTE / argument string
inc(Row);
s := TimeToStr(EncodeTime(9, 59, 20, 0)); // Localization of the test
s := TimeToStr(EncodeTime(9, 59, 20, 0), ExprFormatSettings); // Localization of the test
formula := 'MINUTE("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -1970,7 +1969,7 @@
// MONTH / argument string
inc(Row);
s := DateToStr(EncodeDate(2014, 7, 1)); // Localization of the test
s := DateToStr(EncodeDate(2014, 7, 1), ExprFormatSettings); // Localization of the test
formula := 'MONTH("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -2022,7 +2021,7 @@
// SECOND / argument string
inc(Row);
s := TimeToStr(EncodeTime(9, 59, 20, 0)); // Localization of the test
s := TimeToStr(EncodeTime(9, 59, 20, 0), ExprFormatSettings); // Localization of the test
formula := 'SECOND("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -2054,7 +2053,7 @@
// TIMEVALUE
inc(Row);
s := TimeToStr(EncodeTime(9, 59, 20, 0)); // Localization!
s := TimeToStr(EncodeTime(9, 59, 20, 0), ExprFormatSettings); // Localization!
formula := 'TIMEVALUE("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -2104,7 +2103,7 @@
// WEEKDAY / argument string
inc(Row);
s := DateToStr(EncodeDate(2014, 7, 1)); // Localization of the test
s := DateToStr(EncodeDate(2014, 7, 1), ExprFormatSettings); // Localization of the test
formula := 'WEEKDAY("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then
@@ -2136,7 +2135,7 @@
// YEAR / argument string
inc(Row);
s := DateToStr(EncodeDate(2014, 7, 1)); // Localization of the test
s := DateToStr(EncodeDate(2014, 7, 1), ExprFormatSettings); // Localization of the test
formula := 'YEAR("'+s+'")';
MyWorksheet.WriteText(Row, 0, formula);
if UseRPNFormula then