Errors
All exceptions raised by ExcelTableKit inherit from the base class
ExcelTableKitError and are importable from exceltablekit.errors.
from exceltablekit.errors import (
TableNotDefinedError,
HeaderTableNotDefinedError,
InvalidCellError,
ExcelSheetMissingError,
# ... etc.
)
Base exception
- exception exceltablekit.errors.ExcelTableKitError
Base class for all exceptions in ExcelTableKit. Inherits from the built-in
Exception.from exceltablekit.errors import ExcelTableKitError try: excel.set_table("ZZZ1", "A1") except ExcelTableKitError as e: print(f"ExcelTableKit error: {e}")
Cell validation errors
Raised when a cell address, column, or row value fails validation.
- exception exceltablekit.errors.InvalidCellError(value)[source]
The cell address string is malformed (does not match the pattern
[A-Za-z]+[0-9]+, is longer than 10 characters, or the embedded column / row values are out of bounds).- Parameters:
value – The invalid cell value that was supplied.
Raised by:
set_table(),Validation.from exceltablekit import ExcelManager from exceltablekit.errors import InvalidCellError excel = ExcelManager("output.xlsx") try: excel.set_table("!1", "D10") # invalid column character except InvalidCellError as e: print(e)
- exception exceltablekit.errors.InvalidColumnValueError(value, reason)[source]
The column value is not a non-empty alphabetic string, or the resulting column number exceeds
COLUMN_MAX(16 384 /XFD).- Parameters:
value – The invalid value supplied.
reason – Human-readable explanation of why the value was rejected.
Raised by:
Cell,Validation.
File errors
- exception exceltablekit.errors.ExcelSheetMissingError(sheetname)[source]
The named worksheet does not exist in the workbook, and
create_sheetwas not set toTrue.- Parameters:
sheetname – The sheet name that was looked up.
Raised by:
ExcelManager.from exceltablekit import ExcelManager from exceltablekit.errors import ExcelSheetMissingError try: excel = ExcelManager("report.xlsx", sheetname="NonExistentSheet") except ExcelSheetMissingError as e: print(e)
Table state errors
These are precondition errors raised when methods are called in the wrong order.
- exception exceltablekit.errors.TableNotDefinedError[source]
A style or utility method was called before
set_table().from exceltablekit import ExcelManager, ExcelStyle from exceltablekit.errors import TableNotDefinedError excel = ExcelManager("output.xlsx") style = ExcelStyle(excel) try: style.set_background("E8F4FD") # set_table was not called except TableNotDefinedError: print("Call set_table() first.")
- exception exceltablekit.errors.HeaderTableNotDefinedError[source]
A header style method was called before
define_header().from exceltablekit.errors import HeaderTableNotDefinedError excel.set_table("A1", "D10") # define_header not called try: style.set_header_background("1F4E79") except HeaderTableNotDefinedError: print("Call define_header() first.")
Style application errors
These are raised when openpyxl raises an exception internally during a style operation. They wrap the original exception.
Body style errors:
- exception exceltablekit.errors.TableBackgroundError(error)[source]
Background fill failed on body cells.
Header style errors:
- exception exceltablekit.errors.HeaderTableBackgroundError(error)[source]
Background fill failed on header cells.
- exception exceltablekit.errors.HeaderTableFontError(error)[source]
Font style failed on header cells.
- exception exceltablekit.errors.HeaderTableAlignmentError(error)[source]
Alignment failed on header cells.
- exception exceltablekit.errors.HeaderTableBorderError(error)[source]
Border failed on header cells.
- exception exceltablekit.errors.HeaderTableFreezeError(error)[source]
Freeze panes operation failed.
Utility errors:
Error hierarchy
Exception
└── ExcelTableKitError
├── InvalidCellError
├── InvalidColumnValueError
├── ColumnOutOfBoundsError
├── InvalidRowValueError
├── ExcelSheetMissingError
├── TableNotDefinedError
├── HeaderTableNotDefinedError
├── TableBackgroundError
├── TableFontError
├── TableAlignmentError
├── TableBorderError
├── HeaderTableBackgroundError
├── HeaderTableFontError
├── HeaderTableAlignmentError
├── HeaderTableBorderError
├── HeaderTableFreezeError
└── TableColumnWidthError