@@ -1977,16 +1977,17 @@ def _repr_latex_(self):
1977
1977
# I/O Methods
1978
1978
1979
1979
_shared_docs['to_excel'] = """
1980
- Write %(klass)s to an excel sheet.
1980
+ Write %(klass)s to an Excel sheet.
1981
1981
1982
- To write a single %(klass)s to an excel .xlsx file it is only necessary to
1982
+ To write a single %(klass)s to an Excel .xlsx file it is only necessary to
1983
1983
specify a target file name. To write to multiple sheets it is necessary to
1984
1984
create an `ExcelWriter` object with a target file name, and specify a sheet
1985
- in the file to write to. Multiple sheets may be written to by
1986
- specifying unique `sheet_name`. With all data written to the file it is
1987
- necessary to save the changes. Note that creating an ExcelWriter object
1988
- with a file name that already exists will result in the contents of the
1989
- existing file being erased.
1985
+ in the file to write to.
1986
+
1987
+ Multiple sheets may be written to by specifying unique `sheet_name`.
1988
+ With all data written to the file it is necessary to save the changes.
1989
+ Note that creating an `ExcelWriter` object with a file name that already
1990
+ exists will result in the contents of the existing file being erased.
1990
1991
1991
1992
Parameters
1992
1993
----------
@@ -9951,6 +9952,25 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
9951
9952
if path_or_buf is None:
9952
9953
return formatter.path_or_buf.getvalue()
9953
9954
9955
+ @Appender(_shared_docs["to_excel"] % dict(klass="object"))
9956
+ def to_excel(self, excel_writer, sheet_name="Sheet1", na_rep="",
9957
+ float_format=None, columns=None, header=True, index=True,
9958
+ index_label=None, startrow=0, startcol=0, engine=None,
9959
+ merge_cells=True, encoding=None, inf_rep="inf", verbose=True,
9960
+ freeze_panes=None):
9961
+ df = self if isinstance(self, ABCDataFrame) else self.to_frame()
9962
+
9963
+ from pandas.io.formats.excel import ExcelFormatter
9964
+ formatter = ExcelFormatter(df, na_rep=na_rep, cols=columns,
9965
+ header=header,
9966
+ float_format=float_format, index=index,
9967
+ index_label=index_label,
9968
+ merge_cells=merge_cells,
9969
+ inf_rep=inf_rep)
9970
+ formatter.write(excel_writer, sheet_name=sheet_name, startrow=startrow,
9971
+ startcol=startcol, freeze_panes=freeze_panes,
9972
+ engine=engine)
9973
+
9954
9974
9955
9975
def _doc_parms(cls):
9956
9976
"""Return a tuple of the doc parms."""
0 commit comments