Skip to content

BUG: ExcelWriter creates Excel file with wrong sheet name. #39297

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

Closed
2 of 3 tasks
izanbf1803 opened this issue Jan 20, 2021 · 4 comments
Closed
2 of 3 tasks

BUG: ExcelWriter creates Excel file with wrong sheet name. #39297

izanbf1803 opened this issue Jan 20, 2021 · 4 comments
Labels
Bug IO Excel read_excel, to_excel Upstream issue Issue related to pandas dependency

Comments

@izanbf1803
Copy link

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

writer = pd.ExcelWriter("test.xlsx", engine="openpyxl")
pd.DataFrame().to_excel(writer, sheet_name="sheet", index=False)
writer.save()
pd.read_excel("test.xlsx", sheet_name="sheet")
>> KeyError: 'Worksheet sheet does not exist.'

Problem description

Executing DataFrame.to_excel() with sheet_name="sheet" creates an Excel with a sheet named "sheet1" instead of the requested name "sheet".

Expected Output

An Excel with a sheet named "sheet".

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 9d598a5
python : 3.7.7.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-38-generic
Version : #43~20.04.1-Ubuntu SMP Tue Jan 12 16:39:47 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : es_ES.UTF-8
LOCALE : es_ES.UTF-8

pandas : 1.2.1
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.6
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@izanbf1803 izanbf1803 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 20, 2021
@jmishra01
Copy link

This issue is exactly from openpyxl (engine) side.

If you use a different name for your sheet, openpyxl will create Excel with the requested name.

@izanbf1803
Copy link
Author

In this case, i'll check if this bug is already reported in openpyxl. If it's not reported, i will create a new issue there.

@rhshadrach rhshadrach added the IO Excel read_excel, to_excel label Jan 21, 2021
@rhshadrach
Copy link
Member

Thanks @izanbf1803. Please cross link the issue found or created in case other uses get here.

@rhshadrach rhshadrach added the Upstream issue Issue related to pandas dependency label Jan 21, 2021
@simonjayhawkins simonjayhawkins removed the Needs Triage Issue that has not been reviewed by a pandas team member label Jan 21, 2021
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Jan 21, 2021
@mroeschke
Copy link
Member

Since this is an upstream issue with openpyxl, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Excel read_excel, to_excel Upstream issue Issue related to pandas dependency
Projects
None yet
Development

No branches or pull requests

5 participants