macpie.MACPieExcelWriter#

class macpie.MACPieExcelWriter(*args, **kwargs)#

Class for writing Dataset objects into Excel sheets.

Default is to use the mp_xlsxwriter engine, which is the macpie version of panda’s xlsxwriter engine. It has the best writing performance. The other engine option is mp_openpyxl (the macpie version of the openpyxl engine).

mp_xlsxwriter engine-specific options:

  • autofit_columns - True/False. Whether to autofit columns.

  • strip_carriage_returns - True/False. Whether to strip carriage returns (i.e. “\r”). Otherwise Excel will encode it as “_x000D_”. See jmcnamara/XlsxWriter#680.

Notes

This is the analog of pandas.ExcelWriter, so read the documentation for that class for descriptions of available parameters, notes, and examples.

Examples

writer = mp.MACPieExcelWriter(
    file_path,
    engine="mp_xlsxwriter",
    engine_kwargs={
        "options": {"autofit_columns": True, "strip_carriage_returns": True}
    },
)
__init__(path: FilePath | WriteExcelBuffer | ExcelWriter, engine: str | None = None, date_format: str | None = None, datetime_format: str | None = None, mode: str = 'w', storage_options: StorageOptions = None, if_sheet_exists: str | None = None, engine_kwargs: dict[str, Any] | None = None, **kwargs) None#

Methods

__init__(path[, engine, date_format, ...])

check_extension(ext)

checks that path's extension against the Writer's supported extensions.

close()

synonym for save, to make it more file-like

finalize_sheet_order()

finalized_sheet_order(sheetnames)

highlight_duplicates(sheet_name, column_name)

save()

Save workbook to disk.

sheet_names()

write_cells(cells[, sheet_name, startrow, ...])

Write given formatted cells into Excel an excel sheet

write_excel_dict(excel_dict)

write_tablib_dataset(tlset[, freeze_panes])

Attributes

book

Book instance.

cur_sheet

Current sheet for writing.

date_format

Format string for dates written into Excel files (e.g.

datetime_format

Format string for dates written into Excel files (e.g.

engine

Name of engine.

handles

Handles to Excel sheets.

if_sheet_exists

How to behave when writing to a sheet that already exists in append mode.

path

Path to Excel file.

sheets

Mapping of sheet names to sheet objects.

supported_extensions

Extensions that writer engine supports.