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

Unable to open Modified xlsx file in windows excel #370

Open
vinodprak opened this issue May 20, 2020 · 5 comments
Open

Unable to open Modified xlsx file in windows excel #370

vinodprak opened this issue May 20, 2020 · 5 comments

Comments

@vinodprak
Copy link

vinodprak commented May 20, 2020

Hi

Am trying to change content of cell in few worksheets using 'rubyXL', '~> 3.3.33'. After Modifying and saving am unable to open the sheet in windows excel.

workbook = RubyXL::Parser.parse("test.xlsx")
worksheet = workbook.worksheets[0]
worksheet[1][1].change_contents("dummy_content")
workbook.write("output.xlsx")

Opening the modified file in excel gives me an error We found a problem with some content test.xlsx. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

After clicking yes, file is opened with another error.

Removed Part : /xl/comments1.xml part with xml error (Comments) Load error. Line 10, column 147
Repaired Part : /xl/workbook.xml part with xml error (Workbook) Load error. Line 3, column 0

Is there something am doing wrong ?

@bernica
Copy link

bernica commented Oct 29, 2020

@vinodprak were you able to make it work? @weshatheleopard any feedback? I'm experiencing the same, minor text additions break it.

@weshatheleopard
Copy link
Owner

weshatheleopard commented Oct 29, 2020

@vinodprak you have not attached the file you are having problems with, and thus I cannot investigate. @bernica can you give me your file instead?

@bernica
Copy link

bernica commented Oct 30, 2020

Sure thing, here it is:
error_example.xlsx

After repairing Excel says something like "Repaired part: /xl/workbook.xml XML error part. Line 3, column 147."

@bernica
Copy link

bernica commented Oct 30, 2020

I tried with a MS Excel generated input file and was able to open the output file without problems, then I realized I was editing the same input file, which was Numbers (Mac) generated, so I worked around it by writing the output to a new workbook, although I needed to copy the original data.

@weshatheleopard
Copy link
Owner

@bernica in your particular situation, the file contains some extended info that was generated by Google Sheets that is not a part of standard Excel format. Since it is not a part of the standard, rubyXL is not aware how to deal with it, and just passes it through. However, in the process of saving the data, rubyXL changes the IDs of the elements, and while it corrects those IDs on the elements it knows about, this custom Google Sheets element, it doesn't.

The easiest way to solve your problem is to erase the extension data from the file, by doing f.ext_lst = nil (where f is the object that is holding the spreadsheet) immediately prior to f.save(...).

The file you attached is the file you saved from rubyXL. I might be able to investigate further if you also provide the original file that you loaded into rubyXL.

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

No branches or pull requests

3 participants