Skip to content
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

[2.4.0+] Excel repair warning #49

Closed
sylvainbx opened this issue Oct 4, 2016 · 4 comments
Closed

[2.4.0+] Excel repair warning #49

sylvainbx opened this issue Oct 4, 2016 · 4 comments

Comments

@sylvainbx
Copy link
Member

sylvainbx commented Oct 4, 2016

Opening this as an information notice for users who encounter the following problem:

When opening an Excel export with Excel 2016 (Windows) or Excel Mac 2011 (OSX), a warning dialog appears, asking to repair the file before opening.

This does not affect the export content: data integrity is guaranteed but this can be boring if you export frequently.

This issue is very probably due to a bug in a third party library (axlsx) and was already reported there
(see randym/axlsx#489).

No fixes are expected until axlsx fixes the issue.

As a workaround, you can use LibreOffice Calc (here in french) to open your exports files without any warning.

@sylvainbx sylvainbx added the bug label Oct 4, 2016
@sylvainbx sylvainbx changed the title [2.4.0] Excel repair warning [2.4.0+] Excel repair warning Nov 8, 2016
@alexcvcoelho
Copy link
Contributor

Hi @sylvainbx.

Searching in issues of the axlsx_rails i found this solution here, that worked for me.

In fact, lib rails_axlsx returns a content with encoding error, what I do is use the write method that corrects the encode to write to the file.
I am using the following configuration in Gemfile:

gem 'rubyzip', '= 1.0.0'
gem 'axlsx', '= 2.0.1'
gem 'axlsx_rails', '=0.4.0'

The old code:

File.open(export.file,"w+b") {|f| f.puts content }

The new code:

File.open(export.file,"w+b") {|f| f.write content }

sylvainbx added a commit that referenced this issue Oct 21, 2019
- updated rubyzip to fix a security issue
- updated axlsx and file writing method as a possible fix for #49
@sylvainbx
Copy link
Member Author

Hi @alexcvcoelho, I've updated the code to use f.write as you suggested. I've also updated the gems dependencies to the last versions. This applies starting from release 4.2.1. Feel free to give it a try and make a feedback here if you have Excel.

sylvainbx added a commit that referenced this issue Mar 2, 2020
@sylvainbx
Copy link
Member Author

sylvainbx commented Apr 28, 2021

Office 365 seems to be totally unable to open the exported files.

@sylvainbx
Copy link
Member Author

Fixed in release 5.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants