-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Writer.sheets= ExcelWorkbook cant set attribute 'sheets' #52483
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
Comments
cc @rhshadrach IIRC this was intentional? |
This may be an issue with @sabirjana can you verify the version of |
@Dr-Irv - this issue is about setting the @phofl - Yes, IIRC you can't safely set the sheets attribute, this is deprecated, and then removed in 2.0. I'd like to leave this issue open until it's verified that users can't safely set the sheet attribute (I'd like to just double check). |
Thanks for the response. My openpyxl version is '3.0.10'. I see pip has updated version openpyxl 3.1.2 |
It works if mode='a' is removed (at least with the dev version). And if it was deprecated, it's still on the documentation. |
@DeaMariaLeon - I can't reproduce, can you provide an example? Also, where is setting sheets in the documentation - I look a quick look but didn't see anything. Could have easily missed it. I took a look, if we were to allow a user to set the @sabirjana - try modifying |
The documentation: https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.sheets.html
The resulting file: I even added mode='a' |
Ah, I see. This issue is about setting the sheets property, not just accessing it. Something like |
Apologies then.. |
@DeaMariaLeon Thanks for sharing the code snippet. Yes it works in this case however if I need to open the same excel and now add sheet3 then what's the way. I used following code but writer.book throws error for pandas 2.0
|
This added sheets x6 and 7 for me:
|
@DeaMariaLeon It works with pandas 1.4.4. now let me upgrade to 2.0 and check it. Thanks! |
It works, we can close the issue. Thanks for your help!! |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I get an error AttributeError :can't set attribute 'sheets'
This issue is from version 1.5, I don't get this issue in version 1.4.4
Expected Behavior
na
Installed Versions
2.0
The text was updated successfully, but these errors were encountered: