API reference¶
Top-level functions¶
-
pyxlsb.open_workbook(name, *args, **kwargs)¶ Opens the given workbook file path.
- Parameters
name (str) – The name of the XLSB file to open.
- Returns
The workbook instance for the given file name.
- Return type
Examples
This is typically the entrypoint to start working with an XLSB file:
>>> from pyxlsb import open_workbook >>> with open_workbook('test_files/test.xlsb') as wb: ... print(wb.sheets) ... ['Test']
-
pyxlsb.convert_date(date)¶ Convert an Excel date to a
datetimeinstance.- Parameters
date (int or float) – The numeric Excel date value to convert.
- Returns
The corresponding datetime instance or None if invalid.
- Return type
datetime
Deprecated since version 1.1.0: Will be removed in 1.2.0. Use
convert_dateonWorkbookinstances instead.
Workbook¶
-
class
pyxlsb.workbook.Workbook(pkg)¶ The main Workbook class providing worksheets and other metadata.
-
get_sheet(idx_or_name, with_rels=False)¶ Get a sheet by name or 1-based index.
- Parameters
- Returns
The corresponding worksheet instance.
- Return type
- Raises
IndexError – When the index or name is invalid.
ValueError – For an incompatible index or name type.
Deprecated since version 1.1.0: Will be removed in 1.2.0. Use either
get_sheet_by_indexorget_sheet_by_nameinstead.
-
get_sheet_by_index(idx, with_rels=False)¶ Get a worksheet by index.
- Parameters
- Returns
The corresponding worksheet instance.
- Return type
- Raises
IndexError – When the provided index is out of range.
-
get_sheet_by_name(name, with_rels=False)¶ Get a worksheet by its name.
- Parameters
- Returns
The corresponding worksheet instance.
- Return type
- Raises
IndexError – When the provided name is invalid.
Get a string in the shared string table.
-
convert_date(value)¶ Convert an Excel numeric date value to a
datetimeinstance.- Parameters
- Returns
The equivalent datetime instance or None when invalid.
- Return type
-
convert_time(value)¶ Convert an Excel date fraction time value to a
timeinstance.- Parameters
value (float) – The Excel fractional day value.
- Returns
The equivalent time instance or None if invalid.
- Return type
-
close()¶ Release the resources associated with this workbook.
-
Worksheet¶
-
class
pyxlsb.worksheet.Worksheet(workbook, name, fp, rels_fp=None)¶ A worksheet.
-
rows(sparse=True)¶ Get a row iterator to iterate through the cell data.
- Parameters
sparse (bool, optional) – If empty rows should be skipped, defaults to True
- Yields
Row – The rows in this worksheet.
-
close()¶ Release the resources associated with this worksheet.
-
Cell¶
-
class
pyxlsb.cell.Cell(row, col, value=None, formula=None, style_id=None)¶ A cell in a worksheet.
-
value¶ The cell value.
- Type
mixed
-
property
row_num¶ The row number of this cell.
-
property
string_value¶ The string value of this cell or None if not a string.
-
property
numeric_value¶ The numeric value of this cell or None if not a number.
-
property
bool_value¶ The boolean value of this cell or None if not a boolean.
-
property
date_value¶ The date value of this cell or None if not a numeric cell.
-
property
is_date_formatted¶ If this cell is formatted using a date-like format code.
-
property
c¶ The column number of this cell.
Deprecated since version 1.1.0: Use the
colproperty instead.
-
property
f¶ The formula of this cell.
Deprecated since version 1.1.0: Use the
formulaproperty instead.
-
property
r¶ The row number of this cell.
Deprecated since version 1.1.0: Use the
row_numproperty instead.
-
property
v¶ The value of this cell.
Deprecated since version 1.1.0: Use the
valueor the typed*_valueproperties instead.
-