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

Sheets are returned in the wrong order #19

Closed
mateusmedeiros opened this issue Oct 15, 2015 · 11 comments
Closed

Sheets are returned in the wrong order #19

mateusmedeiros opened this issue Oct 15, 2015 · 11 comments

Comments

@mateusmedeiros
Copy link
Contributor

I have a spreadsheet with 10+ sheets, and I need to access the third one, but when I get the index 2 the sheet returned is the 8th one. The names also seem to be associated wrong, because I get the same results when trying a find by .name().

Creek::Book.new(path).sheets.find { |sheet| sheet.name == 'NAME' }  # returns 8th sheet
Creek::Book.new(path).sheets[2]  # returns 8th sheet

I can't provide the spreadsheet I'm using, but I think it's related to google docs.
I exported the spreadsheet to .xlsx using google sheets and it seems there's a very similar issue on roo that was related to google sheets exported spreadsheets: roo-rb/roo#166

@pythonicrubyist
Copy link
Owner

@mateusmedeiros , was the file originally created as a Google Spreadshheet?

Can you remove the contents from sheets and send me the file with empty sheets? I just need to see how the XML files are formatted.

@mateusmedeiros
Copy link
Contributor Author

I wasn't the one that made it, so I don't know for sure, but I think it was made with Excel.
I imported it on Google Sheets and edited and then exported it, and that's when I faced the bug I described.

I removed the contents and exported it again. I kept the same sheets, order and names of the sheets. See if you can reproduce it with this one.
https://gist.github.com/mateusmedeiros/5f6580ecbb540bcb655d

@pythonicrubyist
Copy link
Owner

Thanks. Let me see if I can fix this.

@mateusmedeiros
Copy link
Contributor Author

Thank you. If there's anything else I can do to help, please let me know.

@mateusmedeiros
Copy link
Contributor Author

Hey, did you already start working in this issue?

I was working at the time I reported this, but now that I’m not, I took a little time to see the code and test some stuff. It seems it's really the same thing that is described in the roo issue I posted. Inside the Sheet class the gem just try to load the sheet#{@index}.xml, but you have to use the r:id from xl/workbook.xml to get the Target attribute of the corresponding Id on xl/_rels/workbook.xml.rels.

If you're not on something already, I can try to hack something and open a PR.

@pythonicrubyist
Copy link
Owner

It would be great if you could make the change and submit a PR. Thanks!

@mateusmedeiros
Copy link
Contributor Author

Done.

See if it's ok to you. The tests are all passing, and this change also solved my problem with the original spreadsheet I used. 😄

@pythonicrubyist
Copy link
Owner

Great!!! I'll review it later today and publish a new version of the gem based on your work. Thanks again!

@mateusmedeiros
Copy link
Contributor Author

No problem :)
If it needs any changes just let me know in the PR.

@pythonicrubyist
Copy link
Owner

Thanks for your valuable contribution. A new version of creek (1.1.1) has been released which includes your latest code change.

@mateusmedeiros
Copy link
Contributor Author

Thanks 👍

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

2 participants