larray.LArray.to_excel¶
-
LArray.to_excel(filepath=None, sheet_name=None, position='A1', overwrite_file=False, clear_sheet=False, header=True, transpose=False, engine=None, *args, **kwargs)[source]¶ Writes array in the specified sheet of specified excel workbook.
Parameters: filepath : str 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.
sheet_name : str 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_name can also refer to the position of the sheet (e.g. 0 for the first sheet, -1 for the last one).
position : str or tuple of integers, optional
Integer position (row, column) must be 1-based. Defaults to ‘A1’.
overwrite_file : bool, optional
Whether or not to overwrite the existing file (or just modify the specified sheet). Defaults to False.
clear_sheet : bool, optional
Whether or not to clear the existing sheet (if any) before writing. Defaults to False.
header : bool, optional
Whether or not to write a header (axes names and labels). Defaults to True.
transpose : bool, optional
Whether or not to transpose the resulting array. This can be used, for example, for writing one dimensional arrays vertically. Defaults to False.
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 = ndrange('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')