Skip to content

Commit 9e20d68

Browse files
author
Joeperdefloep
committed
DOC: added docs to #42222
1 parent f023954 commit 9e20d68

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pandas/io/excel/_base.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -762,19 +762,21 @@ class ExcelWriter(metaclass=abc.ABCMeta):
762762
... "path_to_file.xlsx",
763763
... mode="a",
764764
... engine="openpyxl",
765-
... if_sheet_exists="replace"
765+
... if_sheet_exists="replace",
766766
... ) as writer:
767-
... df.to_excel(writer, sheet_name="Sheet1")
767+
>>> df.to_excel(writer, sheet_name="Sheet1")
768768
769-
You can specify arguments to the underlying engine. For example to not
770-
calculate the result of a formula:
769+
You can also write multiple DataFrames to a single sheet. Note that the
770+
`if_sheet_exists` parameter needs to be set to `write_to` if you are in
771+
append mode:
771772
772-
>>> df = pd.DataFrame(["=1+1"])
773-
... with ExcelWriter(
774-
... "path_to_file.xlsx",
775-
... engine_kwargs={"strings_to_formulas":False}
773+
>>> with ExcelWriter("path_to_file.xlsx",
774+
... mode="a",
775+
... engine="openpyxl",
776+
... if_sheet_exists="write_to",
776777
... ) as writer:
777-
... df.to_excel(writer)
778+
>>> df.to_excel(writer, sheet_name="Sheet1")
779+
>>> df.to_excel(writer, sheet_name="Sheet1", startcol=3)
778780
779781
You can store Excel file in RAM:
780782

0 commit comments

Comments
 (0)