Skip to content
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

Add length validation for Excel DataValidations that are list literals. #187



Copy link

@leowebb leowebb commented Aug 2, 2020


I am not entirely sure if this is a bug, but as I was writing some code to produce a list literal for data validations, I was running into an issue where when I was producing an xlsx, I was unable to open the file in Microsoft Excel due to what I eventually understood to be a hard limit on the size of the data validation literal, which was 255 characters (including separators, excluding quotes). I spoke with a maintainer on IRC about whether this was an issue or not, and he advised that I double check the specifications for OOXML documents. I wasn't able to find anything about limiting the size of formula1 literals, but sure enough if one manually edits the file XML and then opens it in Excel, the user will be presented with an error saying that the file cannot be read by Excel due to some error.

The reason I'm not sure for whether or not is is a bug is due to the specification seemingly being right (these files open just fine in OpenOffice/LibreOffice), but Excel seems to ignore this for whatever reason.

For wholeness, I also checked in the HSSF code, and this limit is enforced there (specifically StringPtgs have a hard limit of 255 ASCII characters, and that is what is used when creating the Data Validations).

Otherwise, assuming this is a bug because Excel cannot open the file but the software still generates the file, then here is a PR to hopefully fix the issue.


Copy link

centic9 commented Aug 2, 2020

Thanks for the contribution.

Any chance you can add a sample file to the test-data/spreadsheet directory and a unit-test which verifies the added length-validation?

Copy link

leowebb commented Aug 2, 2020

Hello! Thank you for the response.

I've added a sample file that won't open in Excel, and a corresponding test that throws an exception from the DataValidation when reading from it. Hopefully this is what you were looking for - still new to the entire code base. If the test should look different, please help me find which files I should be testing against.


@asfgit asfgit closed this in a8d90ab Aug 9, 2020
Copy link

thanks - merged with a8d90ab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
3 participants