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

Error recovery when opening MS Excel: #401

Open
kyalpani opened this issue Jul 3, 2021 · 6 comments
Open

Error recovery when opening MS Excel: #401

kyalpani opened this issue Jul 3, 2021 · 6 comments

Comments

@kyalpani
Copy link

kyalpani commented Jul 3, 2021

Hi, using rubyXL, I am transforming an existing MS-Excel into a new one... When I open the new one, MS-Excel reports an error and tries to fix the errors...

Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.
Removed Records: Named range from /xl/workbook.xml part (Workbook)
Repaired Records: Cell information from /xl/worksheets/sheet7.xml part

The result of the recovery is stored in the file with the following content

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error018760_01.xml</logFileName><summary>Errors were detected in file 'C:\Users\Win10\Downloads\ZZZZZZZ.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>

I unzipped the contents of the original and transformed Excels and compared them (in meld), specifically I compared workbook.xml in both versions and I can see that under the <sheets> tag all "r:id" values are off by 5, i.e. if a sheet in the original version has r:id=X then in the transformed version it has r:id=(X + 5). I checked the rubyXL code and see that in ./lib/rubyXL/objects/relationships.rb:40 says

:id => "rId#{relationships.size + 1}"

and wonder how it could go wrong... obviously when writing out the file somehow
apriori relationships.size == 5
but I do not understand why? Do you have any idea?
Thanks.

@andyzito
Copy link

andyzito commented Dec 8, 2021

I am also having this issue. I'm not even modifying the sheet, just reading it in and saving it to file without any changes:

puts 'READ'
workbook = RubyXL::Parser.parse("./assets_template_base.xlsx")
puts 'WRITE'
workbook.write("./assets_template_rubyxl.xlsx")

@weshatheleopard
Copy link
Owner

@andyzito RubyXL is not perfect, it's the best recreation we can do given the current technologies.

@kyalpani can you please provide the file you are having trouble with?

@andyzito
Copy link

andyzito commented Dec 8, 2021

idk about @kyalpani, but I'm guessing my issue is related to #198.
I'm hoping that the workaround suggested at the end of that issue (importing/exporting with RubyXL, repair with Excel, then use that repaired file as the new base file) will work for our use case 🤞

@weshatheleopard Thanks for maintaining a gem that can do both reading + writing for xlsx 😄

@kyalpani
Copy link
Author

kyalpani commented Dec 8, 2021

I will be glad to help you locate the problem. If there is specific information that you require, I can try to locate it. #198 is certainly related but reopening the excel was not an option in my case. Nonetheless, at least for Excels generated from scratch, RubyXL is an excellent tool.

@mewthu2
Copy link

mewthu2 commented Apr 18, 2022

Hi, using rubyXL, I am transforming an existing MS-Excel into a new one... When I open the new one, MS-Excel reports an error and tries to fix the errors...

Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded. Removed Records: Named range from /xl/workbook.xml part (Workbook) Repaired Records: Cell information from /xl/worksheets/sheet7.xml part

The result of the recovery is stored in the file with the following content

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error018760_01.xml</logFileName><summary>Errors were detected in file 'C:\Users\Win10\Downloads\ZZZZZZZ.xlsx'</summary><additionalInfo><info>Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.</info></additionalInfo></recoveryLog>

I unzipped the contents of the original and transformed Excels and compared them (in meld), specifically I compared workbook.xml in both versions and I can see that under the <sheets> tag all "r:id" values are off by 5, i.e. if a sheet in the original version has r:id=X then in the transformed version it has r:id=(X + 5). I checked the rubyXL code and see that in ./lib/rubyXL/objects/relationships.rb:40 says

:id => "rId#{relationships.size + 1}"

and wonder how it could go wrong... obviously when writing out the file somehow apriori relationships.size == 5 but I do not understand why? Do you have any idea? Thanks.

u can show us a file in question?

@mewthu2
Copy link

mewthu2 commented Apr 18, 2022

idk about @kyalpani, but I'm guessing my issue is related to #198. I'm hoping that the workaround suggested at the end of that issue (importing/exporting with RubyXL, repair with Excel, then use that repaired file as the new base file) will work for our use case 🤞

@weshatheleopard Thanks for maintaining a gem that can do both reading + writing for xlsx 😄

i think u have a path trouble.. try again with path="/tmp" (dont forget to upload file in there)

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

4 participants