larray.Array.to_excel

Array.to_excel(filepath=None, sheet=None, position='A1', overwrite_file=False, clear_sheet=False, header=True, transpose=False, wide=True, value_name='value', engine=None, *args, **kwargs) None[source]

Write array in the specified sheet of specified excel workbook.

Parameters
filepathstr or Path or int or None, optional

Path where the excel file has to be written. If None (default), creates a new Excel Workbook in a live Excel instance (Windows only). Use -1 to use the currently active Excel Workbook. Use a name without extension (.xlsx) to use any unsaved* workbook.

sheetstr or Group or int or None, optional

Sheet where the data has to be written. Defaults to None, Excel standard name if adding a sheet to an existing file, “Sheet1” otherwise. sheet can also refer to the position of the sheet (e.g. 0 for the first sheet, -1 for the last one).

positionstr or tuple of integers, optional

Integer position (row, column) must be 1-based. Used only if engine is ‘xlwings’. Defaults to ‘A1’.

overwrite_filebool, optional

Whether to overwrite the existing file (or just modify the specified sheet). Defaults to False.

clear_sheetbool, optional

Whether to clear the existing sheet (if any) before writing. Defaults to False.

headerbool, optional

Whether to write a header (axes names and labels). Defaults to True.

transposebool, optional

Whether to transpose the array over last axis. This is equivalent to paste with option transpose in Excel. Defaults to False.

wideboolean, optional

Whether writing arrays in “wide” format. If True, arrays are exported with the last axis represented horizontally. If False, arrays are exported in “narrow” format: one column per axis plus one value column. Defaults to True.

value_namestr, optional

Name of the column containing the values (last column) in the Excel sheet when wide=False (see above). Defaults to ‘value’.

engine‘xlwings’ | ‘openpyxl’ | ‘xlsxwriter’ | ‘xlwt’ | None, optional

Engine to use to make the output. If None (default), it will use ‘xlwings’ by default if the module is installed and relies on Pandas default writer otherwise.

*args
**kwargs

Examples

>>> a = ndtest('nat=BE,FO;sex=M,F')
>>> # write to a new (unnamed) sheet
>>> a.to_excel('test.xlsx')  
>>> # write to top-left corner of an existing sheet
>>> a.to_excel('test.xlsx', 'Sheet1')  
>>> # add to existing sheet starting at position A15
>>> a.to_excel('test.xlsx', 'Sheet1', 'A15')