@@ -5979,7 +5979,8 @@ def to_hdf(self, filepath, key, *args, **kwargs):
59795979 key = _translate_key_hdf (key )
59805980 self .to_frame ().to_hdf (filepath , key , * args , ** kwargs )
59815981
5982- def to_excel (self , filepath = None , sheet_name = None , position = 'A1' , overwrite_file = False , clear_sheet = False ,
5982+ @deprecate_kwarg ('sheet_name' , 'sheet' )
5983+ def to_excel (self , filepath = None , sheet = None , position = 'A1' , overwrite_file = False , clear_sheet = False ,
59835984 header = True , transpose = False , wide = True , value_name = 'value' , engine = None , * args , ** kwargs ):
59845985 """
59855986 Writes array in the specified sheet of specified excel workbook.
@@ -5990,9 +5991,9 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
59905991 Path where the excel file has to be written. If None (default), creates a new Excel Workbook in a live Excel
59915992 instance (Windows only). Use -1 to use the currently active Excel Workbook. Use a name without extension
59925993 (.xlsx) to use any unsaved* workbook.
5993- sheet_name : str or Group or int or None, optional
5994+ sheet : str or Group or int or None, optional
59945995 Sheet where the data has to be written. Defaults to None, Excel standard name if adding a sheet to an
5995- existing file, "Sheet1" otherwise. sheet_name can also refer to the position of the sheet
5996+ existing file, "Sheet1" otherwise. sheet can also refer to the position of the sheet
59965997 (e.g. 0 for the first sheet, -1 for the last one).
59975998 position : str or tuple of integers, optional
59985999 Integer position (row, column) must be 1-based. Defaults to 'A1'.
@@ -6028,7 +6029,7 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
60286029 >>> # add to existing sheet starting at position A15
60296030 >>> a.to_excel('test.xlsx', 'Sheet1', 'A15') # doctest: +SKIP
60306031 """
6031- sheet_name = _translate_sheet_name (sheet_name )
6032+ sheet = _translate_sheet_name (sheet )
60326033
60336034 if wide :
60346035 pd_obj = self .to_frame (fold_last_axis_name = True )
@@ -6057,29 +6058,29 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
60576058 wb = open_excel (filepath , overwrite_file = overwrite_file )
60586059
60596060 if new_workbook :
6060- sheet = wb .sheets [0 ]
6061- if sheet_name is not None :
6062- sheet .name = sheet_name
6063- elif sheet_name is not None and sheet_name in wb :
6064- sheet = wb .sheets [sheet_name ]
6061+ sheetobj = wb .sheets [0 ]
6062+ if sheet is not None :
6063+ sheetobj .name = sheet
6064+ elif sheet is not None and sheet in wb :
6065+ sheetobj = wb .sheets [sheet ]
60656066 if clear_sheet :
6066- sheet .clear ()
6067+ sheetobj .clear ()
60676068 else :
6068- sheet = wb .sheets .add (sheet_name , after = wb .sheets [- 1 ])
6069+ sheetobj = wb .sheets .add (sheet , after = wb .sheets [- 1 ])
60696070
60706071 options = dict (header = header , index = header , transpose = transpose )
6071- sheet [position ].options (** options ).value = pd_obj
6072+ sheetobj [position ].options (** options ).value = pd_obj
60726073 # TODO: implement wide via/in dump
60736074 # sheet[position] = self.dump(header=header, wide=wide)
60746075 if close :
60756076 wb .save ()
60766077 wb .close ()
60776078 else :
6078- if sheet_name is None :
6079- sheet_name = 'Sheet1'
6079+ if sheet is None :
6080+ sheet = 'Sheet1'
60806081 # TODO: implement position in this case
60816082 # startrow, startcol
6082- pd_obj .to_excel (filepath , sheet_name , * args , engine = engine , ** kwargs )
6083+ pd_obj .to_excel (filepath , sheet , * args , engine = engine , ** kwargs )
60836084
60846085 def to_clipboard (self , * args , ** kwargs ):
60856086 """Sends the content of the array to clipboard.
0 commit comments