Open
Description
The worksheet name was escaped as HTML since #112.
But It seems to be not working with some special characters, "\b" character for example.
I think it should be escaped as XML.
The following are the character ranges for low-order non-printable ASCII characters that are rejected by MSXML versions 3.0 and later:
#x0 - #x8 (ASCII 0 - 8)
#xB - #xC (ASCII 11 - 12)
#xE - #x1F (ASCII 14 - 31)
Steps to reproduce
- Export an excel file by
aslsx
.
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => "My sheet\b") do |sheet|
sheet.add_row ["Data1", "Data2"]
end
p.serialize('simple1.xlsx')
end
- Double click
simple1.xlsx
to open it.
It will say that the excel is corrupted.
Possible fixes
We can use Builder::XChar.encode
to escape the worksheet name.
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => Builder::XChar.encode("My sheet\b")) do |sheet|
sheet.add_row ["Data1", "Data2"]
end
p.serialize('simple2.xlsx')
end
Metadata
Assignees
Labels
No labels
Activity