A class representing a toolkit for extract detailed cell information
from an Excel file.This class provides methods extracting detailed content from Excel files
(including .xls, .xlsx,.csv), and converting the data into
Markdown formatted table.
Initializes a new instance of the ExcelToolkit class.Parameters:
timeout (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:None)
working_directory (str, optional): The default directory for output files. If not provided, it will be determined by the CAMEL_WORKDIR environment variable (if set). If the environment variable is not set, it defaults to camel_working_dir.
Extract and analyze the full content of an Excel file (.xlsx/.xls/.
csv).Use this tool to read and understand the structure and content of
Excel files. This is typically the first step when working with
existing Excel files.Parameters:
document_path (str): The file path to the Excel file.
Returns:str: A comprehensive report containing:
Sheet names and their content in markdown table format
Detailed cell information including values, colors, and
positions
Formatted data that’s easy to understand and analyze
Create a new Excel workbook from scratch.Use this when you need to create a new Excel file. This sets up the
toolkit to work with the new file and optionally adds initial data.Parameters:
filename (Optional[str]): The filename for the workbook. Must end with .xlsx extension. The file will be saved in self.working_directory. (default: :obj:None)
sheet_name (Optional[str]): Name for the first sheet. If None, creates “Sheet1”. (default: :obj:None)
data (Optional[List[List[Union[str, int, float, None]]]]): Initial data as rows. Each inner list is one row. (default: :obj:None)
Returns:str: Success confirmation message or error details
Get the value from a specific cell.Use this to read a single cell’s value. Useful for checking specific
data points or getting values for calculations.Parameters:
sheet_name (str): Name of the sheet containing the cell.
cell_reference (str): Excel-style cell reference (column letter + row number).
Returns:Union[str, int, float, None]: The cell’s value or error message
Returns None for empty cells.
Set the value of a specific cell.Use this to update individual cells with new values. Useful for
corrections, calculations, or updating specific data points.Parameters:
sheet_name (str): Name of the sheet containing the cell.
cell_reference (str): Excel-style cell reference (column letter + row number).
value (Union[str, int, float, None]): New value for the cell. (default: :obj:None)
Returns:str: Success confirmation message or error details.
Retrieve rows of data from a sheet.Use this to read data from a sheet. You can get all rows or specify a
range. Returns actual data as lists, making it easy to process
programmatically.Parameters:
sheet_name (str): Name of the sheet to read from.
start_row (Optional[int]): First row to read (1-based). If None, starts from row 1. (default: :obj:None)
end_row (Optional[int]): Last row to read (1-based). If None, reads to the end. (default: :obj:None)
Returns:Union[List[List[Union[str, int, float, None]]], str]:
List of rows (each row is a list of cell values) or error
message.
Add a single row to the end of a sheet.Use this to add one row of data to the end of existing content.
For multiple rows, use multiple calls to this function.Parameters:
sheet_name (str): Name of the target sheet.
row_data (List[Union[str, int, float, None]]): Single row of data to add.
Returns:str: Success confirmation message or error details.