-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excel workbooks needing to be recovered #354
Comments
@dwedigital Can you confirm which caxlsx you are using, and which ruby? |
|
Is it possible to have a reproducible test case? require 'axlsx'
p = Axlsx::Package.new
wb = p.workbook
puts "Ruby version: #{RUBY_VERSION}"
puts "Caxlsx version: #{Axlsx::VERSION}"
wb.add_worksheet(name: 'GH Issue 354 Test Case') do |sheet|
# TODO: minimum amount of code to reproduce
end
p.serialize 'gh_issue_354.xlsx' |
tl;dr: It looks like Excel has a different opinion on how an ISO 8601 format works. I've checked the diff between the two xmls and found that Excel reduced the cell definitions from <c r="B6" s="0" t="d">
<v>2021-12-06T14:28:07+00:00</v>
</c> to be only <c r="B6" t="s">
<v>11</v>
</c> I'm not sure why it was replaced with the value My latest code looks like this: wb.add_worksheet(name: 'GH Issue 354 Test Case') do |sheet|
values = [
DateTime.new(2021, 12, 06, 14, 28, 7).iso8601, # breaks Excel
'2021-12-06T14:28:07', # works as expected
'2021-12-06T14:28:07+01:00', # breaks Excel
]
values.each do |value|
sheet.add_row [value, value.match?(Axlsx::ISO_8601_REGEX)] # add `types: [:iso_8601, :boolean]` to be more explicit
end
end The example has three values I try to insert into a cell as an iso8601 formatted value. All three got interpreted as I would change the |
Any excel workbook I create with a basic worksheet is needing to be recovered. I have unzipped the
xlsx
workbook before repair and after repair (see below for the differences between the XML after repair).Is there any issue with out of date schema being used or something obvious I am missing? Once I allow the file to be repaired and save it,, all is OK but would be good to not have this issue in the first place.
Before repair
After repair
The text was updated successfully, but these errors were encountered: