ExcelToolkit
init
- 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 tocamel_working_dir
.
_validate_file_path
- file_path (str): The file path to validate.
_convert_to_markdown
- df (DataFrame): DataFrame containing the Excel data.
extract_excel_content
- document_path (str): The file path to the Excel file.
- 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
_save_workbook
- file_path (str): The path to save the workbook.
save_workbook
- filename (str): The filename to save the workbook. Must end with .xlsx extension. The file will be saved in self. working_directory.
create_workbook
- 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
)
delete_workbook
- filename (str): The filename to delete. Must end with .xlsx extension. The file will be deleted from self. working_directory.
create_sheet
- sheet_name (str): The name of the sheet to create.
- data (Optional[List[List[Union[str, int, float, None]]]]): The data to write to the sheet.
delete_sheet
- sheet_name (str): The name of the sheet to delete.
clear_sheet
- sheet_name (str): The name of the sheet to clear.
delete_rows
- sheet_name (str): Name of the sheet to modify.
- start_row (int): Starting row number to delete (1-based, where 1 is first row).
- end_row (Optional[int]): Ending row number to delete (1-based). If None, deletes only start_row. (default: :obj:
None
)
delete_columns
- sheet_name (str): Name of the sheet to modify.
- start_col (int): Starting column number to delete (1-based, where 1 is column A).
- end_col (Optional[int]): Ending column number to delete (1-based). If None, deletes only start_col. (default: :obj:
None
)
get_cell_value
- sheet_name (str): Name of the sheet containing the cell.
- cell_reference (str): Excel-style cell reference (column letter + row number).
set_cell_value
- 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
)
get_column_data
- sheet_name (str): Name of the sheet to read from.
- column (Union[int, str]): Column identifier - either number (1-based) or letter.
find_cells
- sheet_name (str): Name of the sheet to search in.
- search_value (Union[str, int, float]): Value to search for.
- search_column (Optional[Union[int, str]]): Limit search to specific column. If None, searches entire sheet. (default: :obj:
None
)
get_range_values
- sheet_name (str): Name of the sheet to read from.
- cell_range (str): Range in Excel format (start:end).
set_range_values
- sheet_name (str): Name of the sheet to modify.
- cell_range (str): Range in Excel format to update.
- values (List[List[Union[str, int, float, None]]]): 2D array of values. Each inner list represents a row.
export_sheet_to_csv
- sheet_name (str): Name of the sheet to export.
- csv_filename (str): Filename for the CSV file. Must end with .csv extension. The file will be saved in self.working_directory.
get_rows
- 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
)
append_row
- sheet_name (str): Name of the target sheet.
- row_data (List[Union[str, int, float, None]]): Single row of data to add.
update_row
- sheet_name (str): Name of the sheet to modify.
- row_number (int): The row number to update (1-based, where 1 is first row).
- row_data (List[Union[str, int, float, None]]): New data for the entire row.