xl
Read and Write Excel Files.
Functions
load(xlfile, sheets=[], columns=[], datatype=None, headers=True)
Read data from Excel file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlfile |
str
|
full path of the excel file to read |
required |
sheets |
list
|
worksheets to read. Defaults to all the sheets. |
[]
|
columns |
list
|
Names to give to the columns. It builds a dictionary for each row with the column name and value. If none given (default), it returns a simple list of values. |
[]
|
datatype |
type
|
Type of the data. Defaults to None. |
None
|
headers |
bool
|
Whether to use the first row as headers. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
dict[str, dict[str, Any]]
|
Excel data grouped by worksheet.
Each worksheet is a dictionary with |
Source code in pyrevitlib/pyrevit/interop/xl.py
dump(xlfile, datadict)
Write data to Excel file.
Creates a worksheet for each item of the input dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlfile |
str
|
full path of the target excel file |
required |
datadict |
dict[str, list]
|
dictionary of worksheets names and data |
required |