-
Notifications
You must be signed in to change notification settings - Fork 84
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 2016 unable to open generated document #55
Comments
That's a tough one. It looks like it is Axlsx, but we better be sure. Can you put it entirely in a script (outside of Rake and just using Axlsx) and just use dummy data? Does it work any better without the styles? |
Also, I am curious if you get any different results using |
@straydogstudio sorry for late reply on this. When I run it outside of bundle e.g via console the file appears fine. Removing the styles has no effect. tried looking at Its strange that bundler is appearing to be the issue. |
Ok so I have now managed to get a report to generate without any unable to open errors. Prior I was generating the document in the rake task via report = File.open("./tmp/codeclub-numbers-report-#{Date.today}.xlsx","w+b") {|f| f.puts content } I have now moved this into the s = p.to_stream()
File.open("./tmp/codeclub-numbers-report-#{Date.today}.xlsx", 'w') { |f| f.write(s.read) } I also instead of p = Axlsx::Package.new
wb = p.workbook |
@damienh Thanks for getting back to me. That's an interesting result. It makes me wonder if it's a character set problem. Glad you got it working. FYI, I just published version 0.5.0 with tested support for Rails 5. Version 0.4 works also, but it throws deprecations. |
I'll leave this open. Some time I will get to this and try to replicate the problem. |
Ok, given your fix, I have a guess. The render call is supposed to be using the xlsx template engine, which wraps the template with |
Sometime let me know what Rails, Axlsx, axlsx_rails, and rubyzip versions you're using. |
|
@straydogstudio I'm getting a similar issue that my exported xlsx file is not opening in MS Office and Google Drive. |
@tp-clickapps what Rails, Axlsx, axlsx_rails, and rubyzip versions are you using? Is it in the context of a mailer, or rake task, or...? Can you post a gist of your relevant code? |
@straydogstudio I'm also getting a similar issue. MS Excel 2016 cannot open the generated document, but Numbers can. The document was generated through a rails controller. |
I just noticed that using a worksheet name seemed to make a difference and I was able to open the file in Excel.
|
@jayshepherd Was that with 0.5.0? |
If anyone in this thread is using a special encoding or language let me know. |
@straydogstudio Yes, 0.5.0
|
I am using With this, I am generating an Excel spreadsheet and I am still encountering this issue. Anyone here has any clue regarding how to fix this issue. |
I had an issue with this and fixed it by making sure I wasn't writing past the rows/columns I had generated, which I was doing, I believe. So I had 75 records, but was only writing 26 columns due to a faulty numeric limit I had set, but then I started writing past that in my iterator over the 75 records, this caused me to write into non-existent columns. |
@asampatoor There are a number of issues that can come up. Axlsx and the xlsx format can be picky, and I'm not sure why. A few things to try:
You can also make sure there isn't a problem with axlsx_rails and the rendering context by moving your code into a script and using rails runner. That will confirm if Axlsx or axlsx_rails is the issue. |
@straydogstudio I have turned the shared_strings on in my .axlsx template and also I have passed the layout: false option while rendering. Also, I have the name for the worksheet but still I am getting the same error. |
@asampatoor Can you post your controller code, and template, in a gist? |
@ all, For this issue in my case, The reason I am receiving this error is because of the DateTime format in my data. The DateTime is in is06081 format which excel didn't like it. The Fix I have done: I have added a style format in the styling section And format the iso6081 date as follows |
I just changed this:
to:
and it's working now ;) |
@msdundar Fantastic. I could see the extra new line causing an issue (although it really shouldn't.) Thanks for posting. I'll add a note on this to the troubleshooting section of the README. |
The code that worked from me - |
I get the same error with:
resolved with: |
I am currently trying to create an excel report on my rails app, generated using "--api" and is also experiencing this error right now on the generated excel. Here's the gem versions Here's my controller
here's my
Thank you so much for the help and this wonderful gem |
I was able to fix it by Extending to |
Just wanted to chime in that I ran into the same issue of "Excel file needs to be repaired", and the solution proposed by @msdundar above of using I am using delayed_job to generate these files in the background, and initially followed the "user rails runner" code found here: https://gist.github.com/straydogstudio/323139591f2cc5d48fbc Very helpful to learn how to render the view from a model - just needed to change the rails (4.2.10) |
I ran into this issue today, and in the end the cause of my problem was an accented character in the filename. |
I ran into this today and this helped. |
I have been experiencing issues with opening generated documents with Excel 2016. Excel presents the following message:
If I "Open and Repair" I'm offered the chance to see the log file of what was removed, and the repaired sheet is opened. It's not very helpful...
It appears OSX Numbers has an issue with fonts:
OSX OpenOffice opens it fine without issue.
The report is generated via a rake task. Here is the code that I am generating the doc:
The template is fairly large so here is the main call:
Anyone have any ideas what might be causing this?
The text was updated successfully, but these errors were encountered: