Add New Sheet

Arguments

  • sheetname: str
  • tabname: str = None
  • create_workbook: bool = True

Add new worksheet to workbook. Workbook is created by default if it does not exist.

param sheetname:
 name for sheet
param tabname:name for tab, defaults to None
param create_workbook:
 create workbook if True, defaults to True
raises ValueError:
 error is raised if workbook does not exist and create_workbook is False

Add New Workbook

Arguments

Adds new workbook for Excel application

Close Document

Arguments

  • save_changes: bool = False

Close the active document (if open).

Find First Available Row

Arguments

  • worksheet: typing.Any = None
  • row: int = 1
  • column: int = 1

Find first available free row and cell

param worksheet:
 worksheet to handle, defaults to active worksheet if None
param row:starting row for search, defaults to 1
param column:starting column for search, defaults to 1
return:tuple (row, column) or (None, None) if not found

Open Application

Arguments

  • visible: bool = False
  • display_alerts: bool = False

Open the Excel application.

param visible:show window after opening
param display_alerts:
 show alert popups

Open Workbook

Arguments

  • filename: str

Open Excel by filename

param filename:path to filename

Quit Application

Arguments

  • save_changes: bool = False

Quit the application.

Read From Cells

Arguments

  • worksheet: typing.Any = None
  • row: int = None
  • column: int = None

Read value from cell.

param worksheet:
 worksheet to handle, defaults to active worksheet if None
param row:target row, defaults to None
param column:target row, defaults to None
raises ValueError:
 if cell is not given

Run Macro

Arguments

  • macro_name: str = None

Run Excel macro with given name

param macro_name:
 macro to run

Save Excel

Arguments

Saves Excel file

Save Excel As

Arguments

  • filename: str
  • autofit: bool = False

Save Excel with name if workbook is open

param filename:where to save file
param autofit:autofit cell widths if True, defaults to False

Set Active Worksheet

Arguments

  • sheetname: str = None
  • sheetnumber: int = None

Set active worksheet by either its sheet number or name

param sheetname:
 name of Excel sheet, defaults to None
param sheetnumber:
 index of Excel sheet, defaults to None

Write To Cells

Arguments

  • worksheet: typing.Any = None
  • row: int = None
  • column: int = None
  • value: str = None
  • number_format: str = None
  • formula: str = None

Write value, number_format and/or formula into cell.

param worksheet:
 worksheet to handle, defaults to active worksheet if None
param row:target row, defaults to None
param column:target row, defaults to None
param value:possible value to set, defaults to None
param number_format:
 possible number format to set, defaults to None
param formula:possible format to set, defaults to None
raises ValueError:
 if cell is not given