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:
bigchimp
2014-04-24 09:25:31 +00:00
parent f69a47c902
commit 4d5521d38c
2 changed files with 26 additions and 22 deletions

View File

@ -26,7 +26,7 @@ var
type
{ TSpreadWriteReadFontTests }
//Write to xls/xml file and read back
// Write to xls/xml file and read back
TSpreadWriteReadFontTests = class(TTestCase)
private
protected

View File

@ -25,7 +25,7 @@ const
// Returns an A.. notation based on sheet, row, optional column (e.g. A1).
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;
// Note: using this function instead of GetWorkSheetByName for compatibility with
@ -60,32 +60,19 @@ begin
end;
end;
function CellNotation(WorkSheet: TsWorksheet; Row: integer; Column: integer=0): string;
// Converts column number to A.. notation
function ColumnToLetter(Column: integer): string;
begin
// From 0-based to Excel A1 notation
// 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
begin
if Column < 26 then
Result := Worksheet.Name + '!' + char(Column+65)
Result := char(Column+65)
else
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
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*26) + 65)
else
@ -93,5 +80,22 @@ begin
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.