-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessarily enforces maximum of 31 characters in sheet titles #176
Comments
Thanks for this contribution of quality. Would you be able to find official specs for a few formats about sheet title length ? I'd say at least XLSX and ODS would be nice |
Reviewing the ODS spec, the relevant XML property is table:name. It specifies the data type as "string" without additional constraints. Obviously applications will impose their own limits in terms of what they'll render, but LibreOffice happily opened a file containing an entire paragraph of lorem ipsum. |
See #177 (comment) |
Add option to suppress validation of sheet titles Based on a "lowest common denominator" approach to compatibility, we will continue to enforce a 31-character limit for sheet titles. However, this limit should not be enforced when loading an existing file. Added a new optional parameter to Worksheet::setTitle() and Worksheet::setCodeName() to suppress validation and massaging, based on the premise that existing files should be given a best-effort approach to loading and parsing. Unfortunately, it's not possible with the current architecture to prevent users from making use of this functionality, aside from with a strongly-worded warning. Added test coverage. I didn't see any existing unit tests of the Worksheet class, so I created a new test to cover these methods. Fixes #176
This is:
Summary
XLSX files (at the very least) support sheet titles over 31 characters, but PhpSpreadsheet enforces a 31-character limit regardless of file format. This would be annoying if it only affected sheet creation, but the validation code is also run on load. This means that PhpSpreadsheet is unable to load any valid XLSX file (or file of any other format) containing a sheet with a name over 32 characters.
What is the expected behavior?
A worksheet title containing 32 characters is set correctly. An exception should only be thrown when saving to a format that doesn't support longer titles.
What is the current behavior?
An exception is thrown with the message "Maximum 31 characters allowed in sheet code name.".
What are the steps to reproduce?
(Shows creating a new file, but the same behaviour is encountered when loading an existing file with a sheet title over 31 chars.)
Which versions of PhpSpreadsheet and PHP are affected?
PHPExcel 1.8, PhpSpreadsheet develop
The text was updated successfully, but these errors were encountered: