Column Widths, Especially for ODS #3610
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #3609. Reporter created a spreadsheet with non-adjacent columns having non-default widths. Ods Writer needs to generate entries for the missing columns with default width.
The fix was fairly simple. Testing it was not. Ods Reader basically ignores all styles; they are complicated, declared in (at least) 2 places (content.xml and styles.xml). This change deals only with the problem as reported, in which the missing declarations should be in content.xml. If someone reports a real-world example of this involving styles.xml, I can look at that then. In the meantime, this toehold might serve as a template for adding other style processing to Ods Reader.
Looking at other formats, processing of column widths was also missing from Html Reader, and is now added. Note that this will work only with inline Css declarations on the
col
tags, which can be generated by Html Writer usingsetUseInlineCss(true)
. This creates a much larger file than one created without inline CSS.A general problem became evident when studying the code. Worksheet
columnDimensions
is an unsorted array. This is not a problem per se, but it can easily lead to unexpected results from agetColumnDimensions
call. The code is changed to sort the array before returning it ingetColumnDimensions
.One existing test failed as a result of this change. It erroneously tested
getHighestColumn
instead ofgetHighestDataColumn
, which caused a problem because the final column declaration included anumber-columns-repeated
attribute. The new result forgetHighestColumn
is correct, and the test is changed to usegetHighestDataColumn
instead, which was certainly its intent.This is:
Checklist:
Why this change is needed?
Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.