You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => "good")
p.serialize('good.xlsx')
end
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => "\u{1F1EB 1F1F7}1234567890123456789012345678")
p.serialize('bad.xlsx')
end
The file good.xlsx works fine. The file bad.xlsx displays an error upon opening in Microsoft Excel and asks to repair a corrupted file.
The root cause seems to be the 31 character worksheet name limit. When unicode is used in the worksheet name, the additional bytes don't seem to count toward the 31 character limit. So in this case, a 28- or 29- character "normal" string (after the unicode portion) will not throw an error but will generate a corrupted file. I would recommend updating the error trigger on a too-long name to check string length in bytes instead of just normal string length.
The text was updated successfully, but these errors were encountered:
aardvarkk
pushed a commit
to aardvarkk/axlsx
that referenced
this issue
May 25, 2018
size returns length in characters, but doesn't factor in multibyte Unicode characters.
By switching to bytesize, we check the relevant measure of how many bytes the worksheet name is.
Fixesrandym#588.
size returns length in characters, but doesn't factor in multibyte Unicode characters.
By switching to bytesize, we check the relevant measure of how many bytes the worksheet name is.
Fixesrandym#588.
aardvarkk
pushed a commit
to aardvarkk/axlsx
that referenced
this issue
Dec 16, 2019
- `size` returns length in characters, but doesn't factor in multibyte Unicode characters.
By switching to `bytesize`, we check the relevant measure of how many bytes the worksheet name is.
- Fixesrandym#588
- Copy of PR against original axlsx
(randym#589)
- `size` returns length in characters, but doesn't factor in multibyte Unicode characters.
By switching to `bytesize`, we check the relevant measure of how many bytes the worksheet name is.
- Fixesrandym/axlsx#588
- Copy of PR against original axlsx
(randym/axlsx#589)
Can be reproduced with the following example:
The file
good.xlsx
works fine. The filebad.xlsx
displays an error upon opening in Microsoft Excel and asks to repair a corrupted file.The root cause seems to be the 31 character worksheet name limit. When unicode is used in the worksheet name, the additional bytes don't seem to count toward the 31 character limit. So in this case, a 28- or 29- character "normal" string (after the unicode portion) will not throw an error but will generate a corrupted file. I would recommend updating the error trigger on a too-long name to check string length in bytes instead of just normal string length.
The text was updated successfully, but these errors were encountered: