Skip to content

Commit 0fff857

Browse files
committed
DOC: add type BinaryIO to path param pandas-dev#35505
1 parent a0c8425 commit 0fff857

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pandas/io/excel/_base.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class ExcelWriter(metaclass=abc.ABCMeta):
541541
542542
Parameters
543543
----------
544-
path : str
544+
path : str or BinaryIO
545545
Path to xls or xlsx or ods file.
546546
engine : str (optional)
547547
Engine to use for writing. If None, defaults to
@@ -596,6 +596,21 @@ class ExcelWriter(metaclass=abc.ABCMeta):
596596
597597
>>> with ExcelWriter('path_to_file.xlsx', mode='a') as writer:
598598
... df.to_excel(writer, sheet_name='Sheet3')
599+
600+
You can store Excel file in RAM:
601+
602+
>>> import io
603+
>>> buffer = io.BytesIO()
604+
>>> with pd.ExcelWriter(buffer) as writer:
605+
... df.to_excel(writer)
606+
607+
You can pack Excel file into zip archive:
608+
609+
>>> import zipfile
610+
>>> with zipfile.ZipFile('path_to_file.zip', 'w') as zf:
611+
... with zf.open('filename.xlsx', 'w') as buffer:
612+
... with pd.ExcelWriter(buffer) as writer:
613+
... df.to_excel(writer)
599614
"""
600615

601616
# Defining an ExcelWriter implementation (see abstract methods for more...)

0 commit comments

Comments
 (0)