fpspreadsheet: Workbook.AddWorksheet creates a "duplicate workwheet" error message if new worksheet already exists. Update German translation.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6553 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-07-09 17:49:54 +00:00
parent 4cdb95d86c
commit 25b83a1948
7 changed files with 52 additions and 28 deletions

View File

@@ -8743,8 +8743,12 @@ end;
-------------------------------------------------------------------------------}
function TsWorkbook.AddWorksheet(AName: string;
ReplaceDuplicateName: Boolean = false): TsWorksheet;
var
msg: String;
begin
// Check worksheet name
if not ReplaceDuplicateName and (GetWorksheetByName(AName) <> nil) then
raise EFPSpreadsheet.CreateFmt(rsDuplicateWorksheetName, [AName]);
if not ValidWorksheetName(AName, ReplaceDuplicateName) then
raise EFPSpreadsheet.CreateFmt(rsInvalidWorksheetName, [AName]);
@@ -9094,11 +9098,12 @@ end;
function TsWorkbook.ValidWorksheetName(var AName: String;
ReplaceDuplicateName: Boolean = false): Boolean;
// see: http://stackoverflow.com/questions/451452/valid-characters-for-excel-sheet-names
const
INVALID_CHARS: set of char = ['[', ']', ':', '*', '?', '/', '\'];
var
INVALID_CHARS: array [0..6] of char = ('[', ']', ':', '*', '?', '/', '\');
var
i: Integer;
unique: Boolean;
ch: char;
i: Integer;
begin
Result := false;
@@ -9113,8 +9118,8 @@ begin
exit;
}
// Name must not contain any of the INVALID_CHARS
for i:=0 to High(INVALID_CHARS) do
if UTF8Pos(INVALID_CHARS[i], AName) > 0 then
for ch in AName do
if ch in INVALID_CHARS then
exit;
// Name must be unique

View File

@@ -167,6 +167,7 @@ resourcestring
// Worksheets
rsDefaultSheetName = 'Sheet%d';
rsDuplicateWorksheetName = 'Duplicate worksheet "%s".';
rsInvalidWorksheetName = '"%s" is not a valid worksheet name.';
rsWorksheetNotFound = 'Worksheet "%s" not found.';
rsWorksheetNotFound1 = 'Worksheet not found.';