You've already forked lazarus-ccr
Tests: cosmetic: remove duplicate column number to letter translation code.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2961 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -26,7 +26,7 @@ var
|
|||||||
|
|
||||||
type
|
type
|
||||||
{ TSpreadWriteReadFontTests }
|
{ TSpreadWriteReadFontTests }
|
||||||
//Write to xls/xml file and read back
|
// Write to xls/xml file and read back
|
||||||
TSpreadWriteReadFontTests = class(TTestCase)
|
TSpreadWriteReadFontTests = class(TTestCase)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
|
@@ -25,7 +25,7 @@ const
|
|||||||
// Returns an A.. notation based on sheet, row, optional column (e.g. A1).
|
// Returns an A.. notation based on sheet, row, optional column (e.g. A1).
|
||||||
function CellNotation(WorkSheet: TsWorksheet; Row: integer; Column: integer=0): string;
|
function CellNotation(WorkSheet: TsWorksheet; Row: integer; Column: integer=0): string;
|
||||||
|
|
||||||
// Returns an A notation of column based on sheed and column
|
// Returns an A notation of column based on sheet and column
|
||||||
function ColNotation(WorkSheet: TsWorksheet; Column:Integer): String;
|
function ColNotation(WorkSheet: TsWorksheet; Column:Integer): String;
|
||||||
|
|
||||||
// Note: using this function instead of GetWorkSheetByName for compatibility with
|
// Note: using this function instead of GetWorkSheetByName for compatibility with
|
||||||
@@ -60,32 +60,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CellNotation(WorkSheet: TsWorksheet; Row: integer; Column: integer=0): string;
|
// Converts column number to A.. notation
|
||||||
|
function ColumnToLetter(Column: integer): string;
|
||||||
begin
|
begin
|
||||||
// From 0-based to Excel A1 notation
|
begin
|
||||||
// Only goes from column A to Z...
|
|
||||||
if not(assigned(Worksheet)) then
|
|
||||||
result:='CellNotation: error getting worksheet.'
|
|
||||||
else
|
|
||||||
if Column<26 then
|
|
||||||
result:=WorkSheet.Name+'!'+char(Column+65)+inttostr(Row+1)
|
|
||||||
else
|
|
||||||
result:=WorkSheet.Name+'!'+inttostr(Column+1)+':'+inttostr(Row+1)
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ColNotation(WorkSheet: TsWorksheet; Column:Integer): String;
|
|
||||||
begin
|
|
||||||
if not Assigned(Worksheet) then
|
|
||||||
Result := 'ColNotation: error getting worksheet.'
|
|
||||||
else begin
|
|
||||||
if Column < 26 then
|
if Column < 26 then
|
||||||
Result := Worksheet.Name + '!' + char(Column+65)
|
Result := char(Column+65)
|
||||||
else
|
else
|
||||||
if Column < 26*26 then
|
if Column < 26*26 then
|
||||||
Result := Worksheet.Name + '!' + char(Column div 26 + 65) + char(Column mod 26 + 65)
|
Result := char(Column div 26 + 65) +
|
||||||
|
char(Column mod 26 + 65)
|
||||||
else
|
else
|
||||||
if Column < 26*26*26 then
|
if Column < 26*26*26 then
|
||||||
Result := Worksheet.Name + '!' + char(Column div (26*26) + 65) +
|
Result := char(Column div (26*26) + 65) +
|
||||||
char(Column mod (26*26) div 26 + 65) +
|
char(Column mod (26*26) div 26 + 65) +
|
||||||
char(Column mod (26*26*26) + 65)
|
char(Column mod (26*26*26) + 65)
|
||||||
else
|
else
|
||||||
@@ -93,5 +80,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CellNotation(WorkSheet: TsWorksheet; Row: integer; Column: integer=0): string;
|
||||||
|
begin
|
||||||
|
// From 0-based to Excel A1 notation
|
||||||
|
if not(assigned(Worksheet)) then
|
||||||
|
result:='CellNotation: error getting worksheet.'
|
||||||
|
else
|
||||||
|
result:=WorkSheet.Name+'!'+ColumnToLetter(Column)+inttostr(Row+1)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ColNotation(WorkSheet: TsWorksheet; Column:Integer): String;
|
||||||
|
begin
|
||||||
|
if not Assigned(Worksheet) then
|
||||||
|
Result := 'ColNotation: error getting worksheet.'
|
||||||
|
else
|
||||||
|
Result := WorkSheet.Name + '!' + ColumnToLetter(Column);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user