diff --git a/components/fpspreadsheet/examples/excel2demo/excel2write.lpr b/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
index d23f4a5b9..3d967880a 100644
--- a/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
+++ b/components/fpspreadsheet/examples/excel2demo/excel2write.lpr
@@ -278,15 +278,15 @@ begin
MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyRed, 0, 'USD');
MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyRed, 0, 'USD');
inc(r);
- MyWorksheet.WriteUTF8Text(r, 0, 'nfCurrencyDash, 0 decs');
- MyWorksheet.WriteNumber(r, 1, number, nfCurrencyDash, 0, 'USD');
- MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyDash, 0, 'USD');
- MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyDash, 0, 'USD');
+ MyWorksheet.WriteUTF8Text(r, 0, 'nfAccounting, 0 decs');
+ MyWorksheet.WriteNumber(r, 1, number, nfAccounting, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 2, -number, nfAccounting, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 3, 0.0, nfAccounting, 0, 'USD');
inc(r);
- MyWorksheet.WriteUTF8Text(r, 0, 'nfCurrencyDashRed, 0 decs');
- MyWorksheet.WriteNumber(r, 1, number, nfCurrencyDashRed, 0, 'USD');
- MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyDashRed, 0, 'USD');
- MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyDashRed, 0, 'USD');
+ MyWorksheet.WriteUTF8Text(r, 0, 'nfAccountingRed, 0 decs');
+ MyWorksheet.WriteNumber(r, 1, number, nfAccountingRed, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 2, -number, nfAccountingRed, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 3, 0.0, nfAccountingRed, 0, 'USD');
inc(r, 2);
MyWorksheet.WriteUTF8Text(r, 0, 'nfCustom, "$"#,##0_);("$"#,##0)');
MyWorksheet.WriteNumber(r, 1, number);
diff --git a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
index 9a5e73b47..c4db79c3b 100644
--- a/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
+++ b/components/fpspreadsheet/examples/excel5demo/excel5write.lpr
@@ -285,15 +285,15 @@ begin
MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyRed, 0, 'USD');
MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyRed, 0, 'USD');
inc(r);
- MyWorksheet.WriteUTF8Text(r, 0, 'nfCurrencyDash, 0 decs');
- MyWorksheet.WriteNumber(r, 1, number, nfCurrencyDash, 0, 'USD');
- MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyDash, 0, 'USD');
- MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyDash, 0, 'USD');
+ MyWorksheet.WriteUTF8Text(r, 0, 'nfAccounting, 0 decs');
+ MyWorksheet.WriteNumber(r, 1, number, nfAccounting, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 2, -number, nfAccounting, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 3, 0.0, nfAccounting, 0, 'USD');
inc(r);
- MyWorksheet.WriteUTF8Text(r, 0, 'nfCurrencyDashRed, 0 decs');
- MyWorksheet.WriteNumber(r, 1, number, nfCurrencyDashRed, 0, 'USD');
- MyWorksheet.WriteNumber(r, 2, -number, nfCurrencyDashRed, 0, 'USD');
- MyWorksheet.WriteNumber(r, 3, 0.0, nfCurrencyDashRed, 0, 'USD');
+ MyWorksheet.WriteUTF8Text(r, 0, 'nfAccountingRed, 0 decs');
+ MyWorksheet.WriteNumber(r, 1, number, nfAccountingRed, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 2, -number, nfAccountingRed, 0, 'USD');
+ MyWorksheet.WriteNumber(r, 3, 0.0, nfAccountingRed, 0, 'USD');
inc(r, 2);
MyWorksheet.WriteUTF8Text(r, 0, 'nfCustom, "$"#,##0_);("$"#,##0)');
diff --git a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
index 509603097..3c024608f 100644
--- a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
+++ b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
@@ -107,7 +107,7 @@
-
+
@@ -139,21 +139,22 @@
-
-
+
+
-
+
-
+
+
-
-
+
+
@@ -207,18 +208,22 @@
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
@@ -598,135 +603,142 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/fpspreadsheet/examples/other/test_write_formula.pas b/components/fpspreadsheet/examples/other/test_write_formula.pas
index d30b063c4..83810df09 100644
--- a/components/fpspreadsheet/examples/other/test_write_formula.pas
+++ b/components/fpspreadsheet/examples/other/test_write_formula.pas
@@ -95,7 +95,7 @@ begin
WriteSecondWorksheet();
// Save the spreadsheet to a file
- MyWorkbook.WriteToFile(MyDir + 'test_formula.xls', sfExcel8, False);
+ MyWorkbook.WriteToFile(MyDir + 'test_formula.xls', sfExcel8, True);
// MyWorkbook.WriteToFile(MyDir + 'test_formula.odt', sfOpenDocument, False);
MyWorkbook.Free;
end.
diff --git a/components/fpspreadsheet/fpsopendocument.pas b/components/fpspreadsheet/fpsopendocument.pas
index 1c842b9c3..63c492847 100755
--- a/components/fpspreadsheet/fpsopendocument.pas
+++ b/components/fpspreadsheet/fpsopendocument.pas
@@ -712,26 +712,26 @@ var
j, k: Integer;
CurCell: PCell;
CurRow: array of PCell;
- LastColNum: Cardinal;
+ LastColIndex: Cardinal;
LCell: TCell;
AVLNode: TAVLTreeNode;
begin
- LastColNum := CurSheet.GetLastColNumber;
+ LastColIndex := CurSheet.GetLastColIndex;
// Header
FContent := FContent +
' ' + LineEnding +
' ' + LineEnding;
+ IntToStr(LastColIndex + 1) + '" table:default-cell-style-name="Default"/>' + LineEnding;
// The cells need to be written in order, row by row, cell by cell
- for j := 0 to CurSheet.GetLastRowNumber do
+ for j := 0 to CurSheet.GetLastRowIndex do
begin
FContent := FContent +
' ' + LineEnding;
// Write cells from this row.
- for k := 0 to LastColNum do
+ for k := 0 to LastColIndex do
begin
LCell.Row := j;
LCell.Col := k;
diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas
index 9e2217953..5a4cb13ae 100755
--- a/components/fpspreadsheet/fpspreadsheet.pas
+++ b/components/fpspreadsheet/fpspreadsheet.pas
@@ -401,8 +401,10 @@ type
function GetNextCell(): PCell;
function GetFirstCellOfRow(ARow: Cardinal): PCell;
function GetLastCellOfRow(ARow: Cardinal): PCell;
- function GetLastColNumber: Cardinal;
- function GetLastRowNumber: Cardinal;
+ function GetLastColIndex: Cardinal;
+ function GetLastColNumber: Cardinal; deprecated 'Use GetLastColIndex';
+ function GetLastRowIndex: Cardinal;
+ function GetLastRowNumber: Cardinal; deprecated 'Use GetLastRowIndex';
function ReadAsUTF8Text(ARow, ACol: Cardinal): ansistring; overload;
function ReadAsUTF8Text(ACell: PCell): ansistring; overload;
function ReadAsNumber(ARow, ACol: Cardinal): Double;
@@ -1347,7 +1349,7 @@ begin
end;
{@@
- Returns the 0-based number of the last column with a cell with contents.
+ Returns the 0-based index of the last column with a cell with contents.
If no cells have contents, zero will be returned, which is also a valid value.
@@ -1356,7 +1358,7 @@ end;
@see GetCellCount
}
-function TsWorksheet.GetLastColNumber: Cardinal;
+function TsWorksheet.GetLastColIndex: Cardinal;
var
AVLNode: TAVLTreeNode;
begin
@@ -1373,11 +1375,16 @@ begin
end;
end;
+function TsWorksheet.GetLastColNumber: Cardinal;
+begin
+ Result := GetLastColIndex;
+end;
+
function TsWorksheet.GetFirstCellOfRow(ARow: Cardinal): PCell;
var
c, n: Cardinal;
begin
- n := GetLastColNumber;
+ n := GetLastColIndex;
c := 0;
Result := FindCell(ARow, c);
while (result = nil) and (c < n) do begin
@@ -1390,7 +1397,7 @@ function TsWorksheet.GetLastCellOfRow(ARow: Cardinal): PCell;
var
c, n: Cardinal;
begin
- n := GetLastColNumber;
+ n := GetLastColIndex;
c := n;
Result := FindCell(ARow, c);
while (Result = nil) and (c > 0) do begin
@@ -1400,7 +1407,7 @@ begin
end;
{@@
- Returns the 0-based number of the last row with a cell with contents.
+ Returns the 0-based index of the last row with a cell with contents.
If no cells have contents, zero will be returned, which is also a valid value.
@@ -1409,7 +1416,7 @@ end;
@see GetCellCount
}
-function TsWorksheet.GetLastRowNumber: Cardinal;
+function TsWorksheet.GetLastRowIndex: Cardinal;
var
AVLNode: TAVLTreeNode;
begin
@@ -1420,6 +1427,11 @@ begin
Result := PCell(AVLNode.Data).Row;
end;
+function TsWorksheet.GetLastRowNumber: Cardinal;
+begin
+ Result := GetLastRowIndex;
+end;
+
{@@
Reads the contents of a cell and returns an user readable text
representing the contents of the cell.
diff --git a/components/fpspreadsheet/fpspreadsheetgrid.pas b/components/fpspreadsheet/fpspreadsheetgrid.pas
index 82f92e74a..820f38240 100644
--- a/components/fpspreadsheet/fpspreadsheetgrid.pas
+++ b/components/fpspreadsheet/fpspreadsheetgrid.pas
@@ -2427,8 +2427,8 @@ begin
end;
end else
if FWorksheet <> nil then begin
- ColCount := FWorksheet.GetLastColNumber + 1 + FHeaderCount;
- RowCount := FWorksheet.GetLastRowNumber + 1 + FHeaderCount;
+ ColCount := FWorksheet.GetLastColIndex + 1 + FHeaderCount;
+ RowCount := FWorksheet.GetLastRowIndex + 1 + FHeaderCount;
FixedCols := FFrozenCols + FHeaderCount;
FixedRows := FFrozenRows + FHeaderCount;
if ShowHeaders then begin
diff --git a/components/fpspreadsheet/tests/colortests.pas b/components/fpspreadsheet/tests/colortests.pas
index 9d7b379a4..b9dde4491 100644
--- a/components/fpspreadsheet/tests/colortests.pas
+++ b/components/fpspreadsheet/tests/colortests.pas
@@ -148,7 +148,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, ColorsSheet);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for row := 0 to MyWorksheet.GetLastRowNumber do begin
+ for row := 0 to MyWorksheet.GetLastRowIndex do begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
fail('Error in test code. Failed to get cell.');
@@ -238,7 +238,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, ColorsSheet);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for row := 0 to MyWorksheet.GetLastRowNumber do begin
+ for row := 0 to MyWorksheet.GetLastRowIndex do begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
fail('Error in test code. Failed to get cell.');
diff --git a/components/fpspreadsheet/tests/fonttests.pas b/components/fpspreadsheet/tests/fonttests.pas
index b154f9270..8f00a7768 100644
--- a/components/fpspreadsheet/tests/fonttests.pas
+++ b/components/fpspreadsheet/tests/fonttests.pas
@@ -259,8 +259,8 @@ begin
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
counter := 0;
- for row := 0 to MyWorksheet.GetLastRowNumber do
- for col := 0 to MyWorksheet.GetLastColNumber do begin
+ for row := 0 to MyWorksheet.GetLastRowIndex do
+ for col := 0 to MyWorksheet.GetLastColIndex do begin
if (AFormat = sfExcel2) and (counter = 4) then
break; // Excel 2 allows only 4 fonts
MyCell := MyWorksheet.FindCell(row, col);
diff --git a/components/fpspreadsheet/tests/formattests.pas b/components/fpspreadsheet/tests/formattests.pas
index 69d069ec5..65f24a0ea 100644
--- a/components/fpspreadsheet/tests/formattests.pas
+++ b/components/fpspreadsheet/tests/formattests.pas
@@ -445,7 +445,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, AlignmentSheet);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for row := 0 to MyWorksheet.GetLastRowNumber do
+ for row := 0 to MyWorksheet.GetLastRowIndex do
if AFormat = sfExcel2 then begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
@@ -454,7 +454,7 @@ begin
CheckEquals(horAlign = MyCell^.HorAlignment, true,
'Test saved horizontal alignment mismatch, cell '+CellNotation(MyWorksheet,row,col));
end else
- for col := 0 to MyWorksheet.GetLastColNumber do begin
+ for col := 0 to MyWorksheet.GetLastColIndex do begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
fail('Error in test code. Failed to get cell.');
@@ -525,7 +525,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, BordersSheet);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for col := 0 to MyWorksheet.GetLastColNumber do begin
+ for col := 0 to MyWorksheet.GetLastColIndex do begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
fail('Error in test code. Failed to get cell');
@@ -820,7 +820,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, TextRotationSheet);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for row := 0 to MyWorksheet.GetLastRowNumber do begin
+ for row := 0 to MyWorksheet.GetLastRowIndex do begin
MyCell := MyWorksheet.FindCell(row, col);
if MyCell = nil then
fail('Error in test code. Failed to get cell');
diff --git a/components/fpspreadsheet/tests/formulatests.pas b/components/fpspreadsheet/tests/formulatests.pas
index c11d70a73..864872880 100644
--- a/components/fpspreadsheet/tests/formulatests.pas
+++ b/components/fpspreadsheet/tests/formulatests.pas
@@ -82,8 +82,6 @@ begin
// Open the spreadsheet
MyWorkbook := TsWorkbook.Create;
MyWorkbook.ReadFormulas := true;
-// MyWorkbook.FormatSettings.DecimalSeparator := '.';
-// MyWorkbook.FormatSettings.ShortDateFormat := 'yyyy-mm-dd';
MyWorkbook.ReadFromFile(TempFile, AFormat);
if AFormat = sfExcel2 then
@@ -92,7 +90,7 @@ begin
MyWorksheet := GetWorksheetByName(MyWorkBook, SHEET);
if MyWorksheet=nil then
fail('Error in test code. Failed to get named worksheet');
- for Row := 0 to MyWorksheet.GetLastRowNumber do begin
+ for Row := 0 to MyWorksheet.GetLastRowIndex do begin
cell := MyWorksheet.FindCell(Row, 1);
if (cell <> nil) and (Length(cell^.RPNFormulaValue) > 0) then begin
actual := MyWorksheet.ReadRPNFormulaAsString(cell);
diff --git a/components/fpspreadsheet/wikitable.pas b/components/fpspreadsheet/wikitable.pas
index db1ee88c6..f550fbe37 100644
--- a/components/fpspreadsheet/wikitable.pas
+++ b/components/fpspreadsheet/wikitable.pas
@@ -385,10 +385,10 @@ var
begin
AStrings.Add('{| border="1" cellpadding="2" class="wikitable sortable"');
FWorksheet := Workbook.GetFirstWorksheet();
- for i := 0 to FWorksheet.GetLastRowNumber() do
+ for i := 0 to FWorksheet.GetLastRowIndex() do
begin
AStrings.Add('|-');
- for j := 0 to FWorksheet.GetLastColNumber() do
+ for j := 0 to FWorksheet.GetLastColIndex() do
begin
lCurStr := FWorksheet.ReadAsUTF8Text(i, j);
lCurUsedFormatting := FWorksheet.ReadUsedFormatting(i, j);
diff --git a/components/fpspreadsheet/xlsxooxml.pas b/components/fpspreadsheet/xlsxooxml.pas
index bc278df87..c220ba4fd 100755
--- a/components/fpspreadsheet/xlsxooxml.pas
+++ b/components/fpspreadsheet/xlsxooxml.pas
@@ -314,7 +314,7 @@ var
j, k: Integer;
CurCell: PCell;
CurRow: array of PCell;
- LastColNum: Cardinal;
+ LastColIndex: Cardinal;
LCell: TCell;
AVLNode: TAVLTreeNode;
CellPosText: string;
@@ -322,7 +322,7 @@ begin
FCurSheetNum := Length(FSheets);
SetLength(FSheets, FCurSheetNum + 1);
- LastColNum := CurSheet.GetLastColNumber;
+ LastColIndex := CurSheet.GetLastColIndex;
// Header
FSheets[FCurSheetNum] :=
@@ -334,13 +334,13 @@ begin
' ' + LineEnding;
// The cells need to be written in order, row by row, cell by cell
- for j := 0 to CurSheet.GetLastRowNumber do
+ for j := 0 to CurSheet.GetLastRowIndex do
begin
FSheets[FCurSheetNum] := FSheets[FCurSheetNum] +
- Format(' ', [j+1,LastColNum+1]) + LineEnding;
+ Format(' ', [j+1,LastColIndex+1]) + LineEnding;
// Write cells from this row.
- for k := 0 to LastColNum do
+ for k := 0 to LastColIndex do
begin
LCell.Row := j;
LCell.Col := k;