mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #305] Header or footer string length #244
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#244
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 @vic7tar on GitHub (Sep 8, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/305
Originally assigned to: @jmcnamara on GitHub.
Hello.
Excel requires that the header or footer string must be less than 255 characters.
A simple example.
Running ActiveSheet.PageSetup.LeftHeader = String (253, "Ž") displays exactly 253 Unicode characters in the header, the maximum count including &L.
But to use the worksheet_set_header() function, I have to convert the string “&LŽ…253 times…Ž” to UTF-8 encoding. As a result, the input string for worksheet_set_header() will already be 508 ASCII characters long. As a result, the header and footer on the sheet of the generated book will not be displayed.
@jmcnamara commented on GitHub (Sep 8, 2020):
Correct and there are checks in the libxlsxwriter code for that. Although, there looks like there is a bug that restricts it to 254 characters, I need to check that.
Again, correct.
That isn't the case. If the source file is UTF-8 encoded then there will be only 255 characters in the file. The number of bytes required to make up the UTF-8 string doesn't matter.
However, there is a bug (thanks for pointing that out) in libxlsxwriter where it stores the string in a 255 byte fixed sized buffer.
I'll fix that with a dynamic buffer but in the meantime you can apply the following patch to master:
Then you can compile a program like this (where the source code is UTF-8 encoded):
Which gives the expected output:
Thanks for the bug report. I'll add a test and fix this soon.
@jmcnamara commented on GitHub (Sep 8, 2020):
Fixed on master. Thanks for the report.