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

BUG: xlsxwriter does not handle vertical-align: middle #46213

Closed
1 of 3 tasks
tehunter opened this issue Mar 3, 2022 · 1 comment
Closed
1 of 3 tasks

BUG: xlsxwriter does not handle vertical-align: middle #46213

tehunter opened this issue Mar 3, 2022 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@tehunter
Copy link
Contributor

tehunter commented Mar 3, 2022

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

import pandas as pd

df = pd.DataFrame({"A": [0, 1, 2]}, index=pd.MultiIndex.from_product([["Merged"], ["x", "y", "z"]]))

# Expected
with pd.ExcelWriter("temp1.xlsx", engine="openpyxl") as writer:
    styled.to_excel(writer)

# Unexpected
with pd.ExcelWriter("temp2.xlsx", engine="xlsxwriter") as writer:
    styled.to_excel(writer)

Issue Description

Exporting a DataFrame styled with "vertical-align: middle" does not produce expected output with xlsxwriter engine.

With openpyxl (expected behavior):
openpyxl

With xlsxwriter:
xlsxwriter

The error arises from xlsxwriter expects the vertical align property to be "vcenter", while openpyxl expects "center". The _xlsxwriter._XlsxStyler should translate "center" to "vcenter" for the valign property.

Expected Behavior

openpyxl

Installed Versions

INSTALLED VERSIONS

commit : 06d2301
python : 3.10.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
...
pandas : 1.4.1
numpy : 1.22.0
pytz : 2021.3
dateutil : 2.8.2
pip : 22.0.3
setuptools : 60.2.0
Cython : None
pytest : 7.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.2
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.0.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : 2.8.0
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
zstandard : None

@tehunter tehunter added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 3, 2022
@tehunter
Copy link
Contributor Author

tehunter commented Mar 3, 2022

Sorry, please delete. Duplicate of #30107

@tehunter tehunter closed this as completed Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant