diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas
index 2a98c9b1d..9529e4432 100755
--- a/components/fpspreadsheet/fpspreadsheet.pas
+++ b/components/fpspreadsheet/fpspreadsheet.pas
@@ -287,7 +287,7 @@ const
scPurple = $0C;
scTeal = $0D;
scSilver = $0E;
- scGrey = $0F; scGray = $0F; // redefine to allow different kinds of writing
+ scGrey = $0F; scGray = $0F; // redefine to allow different spelling
scGrey10pct = $10; scGray10pct = $10;
scGrey20pct = $11; scGray20pct = $11;
scOrange = $12;
@@ -1587,8 +1587,8 @@ end;
{@@
Converts a FPSpreadsheet cell position, which is Row, Col in numbers
- and zero based, to a textual representation which is [Col][Row],
- being that the Col is in letters and the row is in 1-based numbers }
+ and zero based - e.g. 0,0 - to a textual representation which is [Col][Row],
+ where the Col is in letters and the row is in 1-based numbers - e.g. A1 }
class function TsWorksheet.CellPosToText(ARow, ACol: Cardinal): string;
begin
Result := GetCellString(ARow, ACol, [rfRelCol, rfRelRow]);
diff --git a/components/fpspreadsheet/fpsutils.pas b/components/fpspreadsheet/fpsutils.pas
index 353e47b98..e0dacb602 100644
--- a/components/fpspreadsheet/fpsutils.pas
+++ b/components/fpspreadsheet/fpsutils.pas
@@ -599,9 +599,9 @@ const
@param AColIndex Zero-based column index
@param AFlags A set containing an entry for column and row if these
addresses are relative.
- @return Excel-type of cell address containing $ characters for absolute
+ @return Excel type of cell address containing $ characters for absolute
address parts.
- @example ARowIndex = 0, AColIndex = 0, AFlags = [rfRow] --> $A1
+ @example ARowIndex = 0, AColIndex = 0, AFlags = [rfRelRow] --> $A1
}
function GetCellString(ARow, ACol: Cardinal; AFlags: TsRelFlags): String;
begin
@@ -621,10 +621,10 @@ end;
@param ACol2 Zero-based index of the last column in the range
@param AFlags A set containing an entry for first and last column and
row if their addresses are relative.
- @return Excel-type of cell address range containing '$' characters for absolute
+ @return Excel type of cell address range containing '$' characters for absolute
address parts and a ':' to separate the first and last cells of the
range
- @example ARow1 = 0, ACol1 = 0, ARow = 2, ACol = 1, AFlags = [rfRow, rfRow2]
+ @example ARow1 = 0, ACol1 = 0, ARow = 2, ACol = 1, AFlags = [rfRelRow, rfRelRow2]
--> $A1:$B3
}
function GetCellRangeString(ARow1, ACol1, ARow2, ACol2: Cardinal; AFlags: TsRelFlags): String;
diff --git a/components/fpspreadsheet/tests/internaltests.pas b/components/fpspreadsheet/tests/internaltests.pas
index 46a5fd9fb..a05b7fe1e 100644
--- a/components/fpspreadsheet/tests/internaltests.pas
+++ b/components/fpspreadsheet/tests/internaltests.pas
@@ -17,7 +17,7 @@ uses
// Instead, add .. to unit search path
Classes, SysUtils, fpcunit, testutils, testregistry,
fpsallformats, fpspreadsheet, xlsbiff8 {and a project requirement for lclbase for utf8 handling},
- testsutility, md5;
+ fpsutils, testsutility, md5;
type
{ TSpreadReadInternalTests }
@@ -33,6 +33,9 @@ type
procedure SetUp; override;
procedure TearDown; override;
published
+ // Tests getting Excel style A1 cell locations from row/column based locations.
+ // Bug 26447
+ procedure TestCellString;
//todo: add more calls, rename sheets, try to get sheets with invalid indexes etc
//(see strings tests for how to deal with expected exceptions)
procedure GetSheetByIndex;
@@ -152,10 +155,17 @@ begin
MyWorkbook.Free;
end;
+procedure TSpreadInternalTests.TestCellString;
+begin
+ CheckEquals('$A$1',GetCellString(0,0,[]));
+ CheckEquals('$Z$1',GetCellString(0,25,[])); //bug 26447
+ CheckEquals('$AA$2',GetCellString(1,26,[])); //just past the last letter
+ CheckEquals('$GW$5',GetCellString(4,204,[])); //some big value
+end;
+
procedure TSpreadInternalTests.SetUp;
begin
-
end;
procedure TSpreadInternalTests.TearDown;
@@ -165,6 +175,8 @@ end;
+
+
initialization
// Register so these tests are included in a full run
RegisterTest(TSpreadInternalTests);
diff --git a/components/fpspreadsheet/tests/spreadtestgui.lpi b/components/fpspreadsheet/tests/spreadtestgui.lpi
index ed06b19d3..2f84e4173 100644
--- a/components/fpspreadsheet/tests/spreadtestgui.lpi
+++ b/components/fpspreadsheet/tests/spreadtestgui.lpi
@@ -80,14 +80,17 @@
+
+
+
@@ -96,14 +99,17 @@
+
+
+
@@ -112,6 +118,7 @@
+
@@ -124,12 +131,10 @@
-
-