diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 4d6a766ad6cfa..daca671f21c95 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -755,6 +755,16 @@ class ExcelWriter(metaclass=abc.ABCMeta): >>> with ExcelWriter("path_to_file.xlsx", mode="a", engine="openpyxl") as writer: ... df.to_excel(writer, sheet_name="Sheet3") + You can specify arguments to the underlying engine. For example to not + calculate the result of a formula: + + >>> df = pd.DataFrame(["=1+1"]) + ... with ExcelWriter( + ... "path_to_file.xlsx", + ... engine_kwargs={"strings_to_formulas":False} + ... ) as writer: + ... df.to_excel(writer) + You can store Excel file in RAM: >>> import io diff --git a/pandas/io/excel/_xlsxwriter.py b/pandas/io/excel/_xlsxwriter.py index 06c73f2c6199e..1d6c71a3d9f20 100644 --- a/pandas/io/excel/_xlsxwriter.py +++ b/pandas/io/excel/_xlsxwriter.py @@ -199,7 +199,7 @@ def __init__( engine_kwargs=engine_kwargs, ) - self.book = Workbook(self.handles.handle, **engine_kwargs) + self.book = Workbook(self.handles.handle, engine_kwargs) def save(self): """ diff --git a/pandas/tests/io/excel/test_xlsxwriter.py b/pandas/tests/io/excel/test_xlsxwriter.py index 79d2f55a9b8ff..80ded9a08ecf0 100644 --- a/pandas/tests/io/excel/test_xlsxwriter.py +++ b/pandas/tests/io/excel/test_xlsxwriter.py @@ -64,6 +64,7 @@ def test_write_append_mode_raises(ext): ExcelWriter(f, engine="xlsxwriter", mode="a") + @pytest.mark.parametrize("nan_inf_to_errors", [True, False]) def test_kwargs(ext, nan_inf_to_errors): # GH 42286