Expose sheet title maximum length as `Worksheet::SHEET_TITLE_MAXIMUM_LENGTH`
Closes #482
This commit is contained in:
parent
83c759e951
commit
275c35c877
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Support to read Xlsm templates with form elements, macros, printer settings, protected elements and back compatibility drawing, and save result without losing important elements of document - [#435](https://github.com/PHPOffice/PhpSpreadsheet/issues/435)
|
- Support to read Xlsm templates with form elements, macros, printer settings, protected elements and back compatibility drawing, and save result without losing important elements of document - [#435](https://github.com/PHPOffice/PhpSpreadsheet/issues/435)
|
||||||
|
- Expose sheet title maximum length as `Worksheet::SHEET_TITLE_MAXIMUM_LENGTH` - [#482](https://github.com/PHPOffice/PhpSpreadsheet/issues/482)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,13 @@ class Worksheet implements IComparable
|
||||||
const SHEETSTATE_HIDDEN = 'hidden';
|
const SHEETSTATE_HIDDEN = 'hidden';
|
||||||
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
|
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum 31 characters allowed for sheet title.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const SHEET_TITLE_MAXIMUM_LENGTH = 31;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid characters in sheet title.
|
* Invalid characters in sheet title.
|
||||||
*
|
*
|
||||||
|
@ -434,9 +441,9 @@ class Worksheet implements IComparable
|
||||||
throw new Exception('Invalid character found in sheet code name');
|
throw new Exception('Invalid character found in sheet code name');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum 31 characters allowed for sheet title
|
// Enforce maximum characters allowed for sheet title
|
||||||
if ($CharCount > 31) {
|
if ($CharCount > self::SHEET_TITLE_MAXIMUM_LENGTH) {
|
||||||
throw new Exception('Maximum 31 characters allowed in sheet code name.');
|
throw new Exception('Maximum ' . self::SHEET_TITLE_MAXIMUM_LENGTH . ' characters allowed in sheet code name.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pValue;
|
return $pValue;
|
||||||
|
@ -458,9 +465,9 @@ class Worksheet implements IComparable
|
||||||
throw new Exception('Invalid character found in sheet title');
|
throw new Exception('Invalid character found in sheet title');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximum 31 characters allowed for sheet title
|
// Enforce maximum characters allowed for sheet title
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 31) {
|
if (Shared\StringHelper::countCharacters($pValue) > self::SHEET_TITLE_MAXIMUM_LENGTH) {
|
||||||
throw new Exception('Maximum 31 characters allowed in sheet title.');
|
throw new Exception('Maximum ' . self::SHEET_TITLE_MAXIMUM_LENGTH . ' characters allowed in sheet title.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pValue;
|
return $pValue;
|
||||||
|
|
Loading…
Reference in New Issue