diff --git a/environment.yml b/environment.yml index 848825c37a160..2b171d097a693 100644 --- a/environment.yml +++ b/environment.yml @@ -78,7 +78,7 @@ dependencies: - fastparquet>=0.3.2 # pandas.read_parquet, DataFrame.to_parquet - html5lib # pandas.read_html - lxml # pandas.read_html - - openpyxl # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile + - openpyxl<=3.0.1 # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile - pyarrow>=0.13.1 # pandas.read_parquet, DataFrame.to_parquet, pandas.read_feather, DataFrame.to_feather - pyqt>=5.9.2 # pandas.read_clipboard - pytables>=3.4.2 # pandas.read_hdf, DataFrame.to_hdf diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index e9b4a5d4e430d..f00329e9c7f81 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -1,5 +1,9 @@ +import os + +import numpy as np import pytest +import pandas as pd from pandas import DataFrame import pandas.util.testing as tm @@ -101,3 +105,21 @@ def test_write_append_mode(ext, mode, expected): for index, cell_value in enumerate(expected): assert wb2.worksheets[index]["A1"].value == cell_value + + +@pytest.mark.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") +def test_to_excel_with_openpyxl_engine(ext, tmpdir): + # GH 29854 + # TODO: Fix this once newer version of openpyxl fixes the bug + df1 = DataFrame({"A": np.linspace(1, 10, 10)}) + df2 = DataFrame({"B": np.linspace(1, 20, 10)}) + df = pd.concat([df1, df2], axis=1) + styled = df.style.applymap( + lambda val: "color: %s" % "red" if val < 0 else "black" + ).highlight_max() + + filename = tmpdir / "styled.xlsx" + styled.to_excel(filename, engine="openpyxl") + + assert filename.exists() + os.remove(filename) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4d0e7ee904294..5f67726a3e476 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -51,7 +51,7 @@ beautifulsoup4>=4.6.0 fastparquet>=0.3.2 html5lib lxml -openpyxl +openpyxl<=3.0.1 pyarrow>=0.13.1 pyqt5>=5.9.2 tables>=3.4.2