Skip to content

Conversation

Aketos
Copy link

@Aketos Aketos commented Apr 6, 2018

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

If the autoSize() calculate a width for a column superior to 255 (maximum Excel width column) the column size is set at minimum width instead of maximum

Copy link
Member

@PowerKiKi PowerKiKi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to contribute, however we would need to have unit tests before this can merged.

@Aketos
Copy link
Author

Aketos commented May 12, 2018

I understand, however, the fix is on an old big function, which is not already unit tested.
I don't know if I will have time to do it for you, I will see

@stale
Copy link

stale bot commented Jul 11, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Jul 11, 2018
@stale stale bot closed this Jul 18, 2018
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this pull request Aug 18, 2025
PR PHPOffice#455 was submitted by @Aketos in 2018. It added no unit tests, so it was not merged, and it eventually went stale. Without the tests, I'm not sure exactly what the user had in mind. But my investigation indicates the following:
- for Xls files, if the column width in the file specifies a value greater than 255, Excel will choose its own width when it opens the file.
- for Xlsx files:
    - Excel does not allow you to set a column width > 255, neither by dragging the column boundary, nor by right-clicking and setting a value, nor by auto-fitting the column width.
    - Nevertheless, if the XML specifies a column width > 255, Excel will honor that value in the displayed spreadsheet, and even write it out if the file is saved.


I have taken a different approach than the original PR, which changed `Worksheet::calculateColumnWidths`. Instead, this PR adds an option to the Xlsx Writer to either restrict column widths to 255 or not. The default is "not" in order to avoid a breaking change. For emulating Excel's behavior, in the unusual situation where it might matter, the user might consider using the non-default option.

This PR also restricts column dimension width to 255 when saving an Xls file.
@oleibman oleibman mentioned this pull request Aug 18, 2025
11 tasks
@oleibman
Copy link
Collaborator

Superseded by PR #4581. Removing stale label, leaving closed.

@oleibman oleibman removed the stale label Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants