mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #495] Feature: Allow setting column widths not snapped to pixel grid #387
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#387
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @desttinghim on GitHub (Nov 12, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/495
I was trying to match the formatting of an existing excel report in an internal application I am working on. When trying to match the column widths, I couldn't get the size to exactly match. After digging around in the code and analyzing the logic, I realized that the current code is snapping column widths to integer pixel coordinates. This seems to be an arbitrary limitation and existing XLSX files appear to use subpixel widths. Snapping to pixel widths seems like a good default, so I propose adding new functions for setting column widths. These are the functions I propose adding:
Out of the four proposed functions, only the _raw variant is really necessary, the others are easy enough write wrapper functions for if it is implemented.
@jmcnamara commented on GitHub (Nov 12, 2025):
I have never seen that, at least not in files generated by Excel.
You can verify that Excel uses pixel widths by trying to set an arbitrary width that doesn't snap to the nearest pixel.
If your target file was created in Excel then it is possible that you are seeing an artifact of how Excel on macOS render widths differently than Excel on Windows. Mac users of Excel (outside of libxlsxwriter) often complain about that since it can change image dimensions.
If you have or can create a sample file to demonstrate what you mean then please upload it.
@desttinghim commented on GitHub (Nov 12, 2025):
The excel file I am looking at was generated by another program, so it's possible that is the root of the issue. Oh, I probably should mention I've been viewing the files mostly with libreoffice, but the file was not created or modified with libreoffice. I'm not sure if I can upload the file, I'll have to get back to you on that.
@jmcnamara commented on GitHub (Nov 12, 2025):
No worries. If it wasn't generated by Excel it won't be useful.
@jmcnamara commented on GitHub (Nov 16, 2025):
I'm going to close this because Excel uses pixel precision for positioning and libxlsxwriter needs to adhere to that.