You've already forked lazarus-ccr
fpspreadsheet: Move check for sheet name length to writer -> Sheet names can be any length now. But saving to Excel will abort if there are more than 31 characters.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4656 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -7861,10 +7861,12 @@ begin
|
|||||||
if (AName = '') then
|
if (AName = '') then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
{ wp: the length restriction has been moved to the writer...
|
||||||
|
|
||||||
// Length must be less than 31 characters
|
// Length must be less than 31 characters
|
||||||
if UTF8Length(AName) > 31 then
|
if UTF8Length(AName) > 31 then
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
// Name must not contain any of the INVALID_CHARS
|
// Name must not contain any of the INVALID_CHARS
|
||||||
for i:=0 to High(INVALID_CHARS) do
|
for i:=0 to High(INVALID_CHARS) do
|
||||||
if UTF8Pos(INVALID_CHARS[i], AName) > 0 then
|
if UTF8Pos(INVALID_CHARS[i], AName) > 0 then
|
||||||
|
@ -184,7 +184,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math,
|
Math, LazUTF8,
|
||||||
fpsStrings, fpsUtils, fpsNumFormat, fpsStreams, fpsRegFileFormats;
|
fpsStrings, fpsUtils, fpsNumFormat, fpsStreams, fpsRegFileFormats;
|
||||||
|
|
||||||
|
|
||||||
@ -208,6 +208,7 @@ begin
|
|||||||
FLimitations.MaxColCount := 256;
|
FLimitations.MaxColCount := 256;
|
||||||
FLimitations.MaxRowCount := 65536;
|
FLimitations.MaxRowCount := 65536;
|
||||||
FLimitations.MaxPaletteSize := MaxInt;
|
FLimitations.MaxPaletteSize := MaxInt;
|
||||||
|
FLimitations.MaxSheetnameLength := MaxInt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -230,6 +231,8 @@ end;
|
|||||||
procedure TsBasicSpreadWriter.CheckLimitations;
|
procedure TsBasicSpreadWriter.CheckLimitations;
|
||||||
var
|
var
|
||||||
lastCol, lastRow: Cardinal;
|
lastCol, lastRow: Cardinal;
|
||||||
|
i: Integer;
|
||||||
|
sheet: TsWorksheet;
|
||||||
begin
|
begin
|
||||||
Workbook.GetLastRowColIndex(lastRow, lastCol);
|
Workbook.GetLastRowColIndex(lastRow, lastCol);
|
||||||
|
|
||||||
@ -240,6 +243,18 @@ begin
|
|||||||
// Check column count
|
// Check column count
|
||||||
if lastCol >= FLimitations.MaxColCount then
|
if lastCol >= FLimitations.MaxColCount then
|
||||||
Workbook.AddErrorMsg(rsMaxColsExceeded, [lastCol+1, FLimitations.MaxColCount]);
|
Workbook.AddErrorMsg(rsMaxColsExceeded, [lastCol+1, FLimitations.MaxColCount]);
|
||||||
|
|
||||||
|
// Check worksheet names
|
||||||
|
for i:=0 to Workbook.GetWorksheetCount-1 do
|
||||||
|
begin
|
||||||
|
sheet := Workbook.GetWorksheetByIndex(i);
|
||||||
|
if UTF8Length(sheet.Name) > FLimitations.MaxSheetNameLength then
|
||||||
|
// Worksheet name is too long.
|
||||||
|
// We abort saving here because it is not safe to chop the sheet name
|
||||||
|
// to its allowed length - it may be used as a reference in formulas.
|
||||||
|
raise Exception.CreateFmt(rsWriteError_WorksheetNameTooLong,
|
||||||
|
[sheet.Name, FLimitations.MaxSheetNameLength]);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ resourcestring
|
|||||||
'the best-matching palette colors.';
|
'the best-matching palette colors.';
|
||||||
rsTruncateTooLongCellText = 'Text value exceeds the %d character limit in ' +
|
rsTruncateTooLongCellText = 'Text value exceeds the %d character limit in ' +
|
||||||
'cell %s and has been truncated.';
|
'cell %s and has been truncated.';
|
||||||
|
rsWriteError_WorksheetNameTooLong = 'File cannot be written because ' +
|
||||||
|
'the name of worksheet "%0:s" is too long (max %1:d characters).';
|
||||||
|
|
||||||
// Cells
|
// Cells
|
||||||
rsInvalidCharacterInCell = 'Invalid character(s) in cell %s.';
|
rsInvalidCharacterInCell = 'Invalid character(s) in cell %s.';
|
||||||
|
@ -44,6 +44,7 @@ type
|
|||||||
MaxRowCount: Cardinal;
|
MaxRowCount: Cardinal;
|
||||||
MaxColCount: Cardinal;
|
MaxColCount: Cardinal;
|
||||||
MaxPaletteSize: Integer;
|
MaxPaletteSize: Integer;
|
||||||
|
MaxSheetNameLength: Integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -412,6 +412,10 @@ msgstr "Arbeitsblatt \"%s\" nicht gefunden"
|
|||||||
msgid "Worksheet not found."
|
msgid "Worksheet not found."
|
||||||
msgstr "Arbeitsblatt nicht gefunden."
|
msgstr "Arbeitsblatt nicht gefunden."
|
||||||
|
|
||||||
|
#: fpsstrings.rswriteerror_worksheetnametoolong
|
||||||
|
msgid "File cannot be written because the name of worksheet \"%0:s\" is too long (max %1:d characters)."
|
||||||
|
msgstr "Die Datei kann nicht geschrieben werden, weil der Name des Arbeitsblattes \"%0s:s\" zu lang ist (höchstens %1:d Zeichen)."
|
||||||
|
|
||||||
#: fpsstrings.rsyellow
|
#: fpsstrings.rsyellow
|
||||||
msgid "yellow"
|
msgid "yellow"
|
||||||
msgstr "gelb"
|
msgstr "gelb"
|
||||||
|
@ -401,6 +401,10 @@ msgstr ""
|
|||||||
msgid "Worksheet not found."
|
msgid "Worksheet not found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: fpsstrings.rswriteerror_worksheetnametoolong
|
||||||
|
msgid "File cannot be written because the name of worksheet \"%0:s\" is too long (max %1:d characters)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: fpsstrings.rsyellow
|
#: fpsstrings.rsyellow
|
||||||
msgid "yellow"
|
msgid "yellow"
|
||||||
msgstr "keltainen"
|
msgstr "keltainen"
|
||||||
|
@ -411,6 +411,10 @@ msgstr "A(z) \"%s\" munkalap nem található."
|
|||||||
msgid "Worksheet not found."
|
msgid "Worksheet not found."
|
||||||
msgstr "A munkalap nem található."
|
msgstr "A munkalap nem található."
|
||||||
|
|
||||||
|
#: fpsstrings.rswriteerror_worksheetnametoolong
|
||||||
|
msgid "File cannot be written because the name of worksheet \"%0:s\" is too long (max %1:d characters)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: fpsstrings.rsyellow
|
#: fpsstrings.rsyellow
|
||||||
msgid "yellow"
|
msgid "yellow"
|
||||||
msgstr "sárga"
|
msgstr "sárga"
|
||||||
|
@ -401,6 +401,10 @@ msgstr ""
|
|||||||
msgid "Worksheet not found."
|
msgid "Worksheet not found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: fpsstrings.rswriteerror_worksheetnametoolong
|
||||||
|
msgid "File cannot be written because the name of worksheet \"%0:s\" is too long (max %1:d characters)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: fpsstrings.rsyellow
|
#: fpsstrings.rsyellow
|
||||||
msgid "yellow"
|
msgid "yellow"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -401,6 +401,10 @@ msgstr "Лист таблицы \"%s\" не найден."
|
|||||||
msgid "Worksheet not found."
|
msgid "Worksheet not found."
|
||||||
msgstr "Лист таблицы не найден"
|
msgstr "Лист таблицы не найден"
|
||||||
|
|
||||||
|
#: fpsstrings.rswriteerror_worksheetnametoolong
|
||||||
|
msgid "File cannot be written because the name of worksheet \"%0:s\" is too long (max %1:d characters)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: fpsstrings.rsyellow
|
#: fpsstrings.rsyellow
|
||||||
msgid "yellow"
|
msgid "yellow"
|
||||||
msgstr "жёлтый"
|
msgstr "жёлтый"
|
||||||
|
@ -2853,6 +2853,7 @@ begin
|
|||||||
FLimitations.MaxColCount := 256;
|
FLimitations.MaxColCount := 256;
|
||||||
FLimitations.MaxRowCount := 65536;
|
FLimitations.MaxRowCount := 65536;
|
||||||
FLimitations.MaxPaletteSize := 64;
|
FLimitations.MaxPaletteSize := 64;
|
||||||
|
FLimitations.MaxSheetNameLength := 31;
|
||||||
|
|
||||||
// Initial base date in case it won't be set otherwise.
|
// Initial base date in case it won't be set otherwise.
|
||||||
// Use 1900 to get a bit more range between 1900..1904.
|
// Use 1900 to get a bit more range between 1900..1904.
|
||||||
|
@ -2220,6 +2220,7 @@ begin
|
|||||||
// http://en.wikipedia.org/wiki/List_of_spreadsheet_software#Specifications
|
// http://en.wikipedia.org/wiki/List_of_spreadsheet_software#Specifications
|
||||||
FLimitations.MaxColCount := 16384;
|
FLimitations.MaxColCount := 16384;
|
||||||
FLimitations.MaxRowCount := 1048576;
|
FLimitations.MaxRowCount := 1048576;
|
||||||
|
FLimitations.MaxSheetNameLength := 31;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user