revitron.excel¶
This submodule contains helper classes to access and modify Microsoft Excel files. The following example demonstrates how to write data to table cells in a sheet created from a template:
book = revitron.ExcelWorkbook(xlsx)
sheet = book.newWorksheetFromTemplate('Template', 'Name')
sheet.setCell(5, 1, 'Value')
Classes:
|
A wrapper class for Excel workbooks. |
|
A wrapper class for modifying Excel worksheet cells. |
- class ExcelWorkbook(file)[source]¶
Bases:
object
A wrapper class for Excel workbooks.
Methods:
__init__
(file)Inits a new ExcelWorkbook instance.
close
([save])Closes and optionally saves a workbook file.
getWorksheet
(name)Returns a Excel worksheet for a given name
newWorksheetFromTemplate
(template, name)Creates a new worksheet as a copy from a given template.
- __init__(file)[source]¶
Inits a new ExcelWorkbook instance.
- Parameters
file (string) – The path to the xls file
- close(save=True)[source]¶
Closes and optionally saves a workbook file.
- Parameters
save (bool, optional) – If True, the file is saved before closing. Defaults to True.
- class ExcelWorksheet(worksheet)[source]¶
Bases:
object
A wrapper class for modifying Excel worksheet cells.
Methods:
__init__
(worksheet)Inits a new ExcelWorksheet instance.
setCell
(row, column, value)Writes data to a cell of the current worksheet.