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

iPhone 6 (IOS 10.2.1) Unable to Open ClosedXML generated XLSX files from Gmail.com #279

Closed
1 of 2 tasks
ajstadlin opened this issue Apr 18, 2017 · 28 comments
Closed
1 of 2 tasks
Assignees
Labels

Comments

@ajstadlin
Copy link

ajstadlin commented Apr 18, 2017

Requesting a feature

  • Bug
  • Feature

What is the current behavior?

When opening a ClosedXML XLSX file attachment from Gmail.com using Safari on iPhone 6 the following message is displayed in an https://mail-attachment.google.com... web page

ERROR_MESSAGE_MAIN
ERROR_MESSAGE_REASON

Steps to reproduce:

  • Create a new Visual Studio 2015 Pro, .NET 4.6.1 Project
  XLWorkbook myWorkbook = new XLWorkbook();
  IXLWorksheet myWorksheet = myWorkbook.Worksheets.Add("mySheet1");
  // do stuff to create a worksheet
  myWorkbook.SaveAs("myWorkbookFile.xlsx");
  // attach to email and send

What is the expected behavior or new feature?

iPhone should be able to open the XLXS file from a gmail attachment. No problems opening the XLSX file on a PC running LibreOffice.Calc or MSOffice.Excel. I do not want to install regular Excel on my iPhone. My iPhone opens XLSX files created with regular Excel OK. I only need the ability to View XLSX files on the iPhone, not edit them. ClosedXML files open OK on my Android phone.

Did this work in previous versions of our tool? Which versions?

Did not work in 0.80.x. Does not work in 0.87.x.

It would be really nice to have a ClosedXML feature that allows its files to be viewed by default iPhone viewer.

Thank you - and keep up the great work on this project!

//aj

@igitur
Copy link
Member

igitur commented Apr 18, 2017

I don't have an iPhone, so I have no way to test this. If you can fiddle in the xlsx content and find the problem, I might be able to fix it.

@AmirBosch
Copy link
Contributor

i just tried this, it works, how are you sending an email ? automated or manually ?

@igitur
Copy link
Member

igitur commented Apr 18, 2017

@ajstadlin
Copy link
Author

After viewing some of the StackOverflows on this issue, troubleshooting this problem beyond just setting attachment mime type and encoding is beyond my capacity at this time. Since I have hundreds of PCs and only 3 iPhones; and it works on PCs and Android devices just fine - I'll chalk it up to a iPhone/iOS incompatibility with ClosedXML XLSX files problem for now until someone figures it out how to make it a working feature.

I tried various mime type and transfer settings for .NET email attachments. I tried Safari and the Gmail App, which both try to open the XLSX with Google Sheets - and fail with the error messages I described.

I will monitor this thread in case anyone decides to tackle the problem and get it to work or until it is closed if no one is interested in solving the problem.

Thanks!

@igitur
Copy link
Member

igitur commented Apr 18, 2017

Edit your original post and make the code sample fully reproducible. Inserting comments where the email is sent isn't very helpful. Basically, I want to copy and paste your code and reproduce your result with almost no intervention.

@igitur
Copy link
Member

igitur commented Apr 18, 2017

Also, have you opened and saved the file in regular Excel and then tried mailing it programmatically?

@ajstadlin
Copy link
Author

Follow-up - I installed Excel on my iPhone and, if I access my Gmail through the Gmail App instead of Safari or Google Sheets, I can transfer the attachment to Excel and open it OK. The problem is probably related to Apple Safari and/or Google Sheets incompatibility with ClosedXML XLSX format.

@ajstadlin
Copy link
Author

Some people posted in forums that the XLSX files are "fixed" when opened in MS Excel and then re-saved.

I will prepare a minimal test app and post it.

@ajstadlin
Copy link
Author

@AmirBosch
Copy link
Contributor

ok i can reproduce this now

@AmirBosch AmirBosch self-assigned this Apr 19, 2017
@AmirBosch
Copy link
Contributor

@igitur we might have to open bug with openxml guys,

it seems Open XML SDK, for whatever reason, doesn’t explicitly set the PartName=”/xl/workbook.xml” part. This is why iOS devices can’t see the spreadsheet file. but when you save with excel it gets set

@AmirBosch
Copy link
Contributor

i even tried the latest

@igitur
Copy link
Member

igitur commented Apr 21, 2017

Well spotted, @Pyropace . Is this missing part in the [Content_Types].xml file?

@igitur
Copy link
Member

igitur commented Apr 21, 2017

@Pyropace I found a different cause for the problem: absolute paths in the .rels files. I attach 2 files. One should be broken on the iPhone and one should work. Only difference is in /xl/_rels/workbooks.xml.rels - notice the absolute vs relative urls.
success.xlsx
fail.xlsx

@Pyropace , @ajstadlin Please confirm whether you experience the same.

Thanks to @parautenbach for his help with this.

@parautenbach
Copy link

You're welcome @igitur!

@AmirBosch
Copy link
Contributor

@igitur confirmed

@AmirBosch AmirBosch assigned igitur and unassigned AmirBosch Apr 22, 2017
@igitur
Copy link
Member

igitur commented Apr 26, 2017

No feedback from @ajstadlin . Closing this. Must be a Safari bug, and any workaround would have to be in System.IO.Packaging anyway.

@kbensen1
Copy link

Hi @igitur - what type of feedback were you looking for from @ajstadlin? I have also had this same issue with all spreadsheets created through ClosedXML. I reviewed the two spreadsheets you attached and tried to open both on an iPhone without using Excel. The success file opens fine. The fail file provides the error messages and does not open. I manually modified the /xl/_rels/workbooks.xml.rels in the fail file, removing the "/xl/" from the URL's and then sent the file back to the iPhone and confirmed it could be viewed in ios. Is there any other way around this? Any other suggestions on a way to make the ClosedXML files viewable in ios without modifying the URL's in /xl/_rels/workbooks.xml.rels ?

@igitur
Copy link
Member

igitur commented Apr 26, 2017

Nope, there's nothing we can do. ClosedXML is a wrapper around OpenXML and that uses A DOTNET library to package the contents.

@kbensen1
Copy link

Thanks @igitur! It makes sense, and at least we understand where the issue lies. I appreciate the information!

@ajstadlin
Copy link
Author

ajstadlin commented Apr 27, 2017

Sorry for the lack of feedback. Troubleshooting this issue is currently beyond my capacity. However, if the issue is solved by simply removing "/xl/" from "/xl/_rels/workbooks.xml.rels", I can simply do that by post processing the XLSX files after creating them and before sending them by email or text messaging - just in case one of my users has an iPhone device.

Thank you for your great work on ClosedXML!

@igitur
Copy link
Member

igitur commented Apr 27, 2017

@ajstadlin You might want to submit a bug with Apple too. It's definitely their bug.

@MichalJakubeczy
Copy link

Has anyone made a workaround to mitigate this issue?

@vikasChauhan77
Copy link

If we use any other library like NPOI, etc. , will we face the same issue??

@AZ2Tonez
Copy link

AZ2Tonez commented Feb 16, 2018

@igitur or @ajstadlin: any sample code available for what exactly you did to make the changes to the success.xlsx file that made it work vs. the fail.xlsx? I can confirm that success does indeed work for me on ios and fail does not, but I'm a little unclear on what was done - I searched my exported file for the string "/xl/_rels/workbooks.xml.rels" and it was not found, tho there were 5-6 occurrences of "/xl/" - should I just remove all of those? I hate blindly removing data from the file that might cause other issues for people down the line trying to view the files without understanding the file format. Can you elaborate on what the code might look like to do this post-processing step? Seems like it'd be a universally useful and generic snippet of workaround code.

@vikasChauhan77: I can confirm that we had similar issues with NPOI, but the error message was slightly different - the "ERROR_MESSAGE_MAIN" was the same, but the reason was listed as "The operation couldn't be completed. (OfficeImportErrorDomain error 912.)". This was the main impetus behind switching to ClosedXML in the first place, but alas, we have run into the issue mentioned in this bug (though I also MUCH prefer ClosedXML's api :)).

@igitur
Copy link
Member

igitur commented Feb 16, 2018

Sorry, I don't have code to fix it. I made the changes by hand.

@AZ2Tonez
Copy link

@igitur: Can you comment on the other questions that were asked?

  • I searched my exported file for the string "/xl/_rels/workbooks.xml.rels" and it was not found, tho there were 5-6 occurrences of "/xl/" - should I just remove all of those?
  • Can you elaborate on what the code might look like to do this post-processing step?

@igitur
Copy link
Member

igitur commented Feb 17, 2018

@AZ2Tonez Here is the diff of the 2 versions:

Left: successful opening of file on iPhone. Right: fail opening of file on iPhone.
So if you want to get this to work, you have to patch the files inside the .xlsx file to fix the differences. How you do that is up to you. I've never done it.

image

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

No branches or pull requests

8 participants