添加 Sheet 到 Excel
xlsx_add_sheetDestructive
Add a new sheet to an existing xlsx file by providing the file path, JSON data, and a unique sheet name.
Instructions
向已有的 xlsx 文件中添加新的 sheet。
参数:
file_path (string, 必填): 已存在的 xlsx 文件路径
data (string, 必填): JSON 数据字符串 (同 xlsx_create 的 data 参数)
sheet_name (string, 必填): 新 sheet 名称 (不能与已有 sheet 重名)
返回:
file_path: 文件路径
sheet_name: 新 sheet 名称
rows: 数据行数
cols: 数据列数
sheets: 更新后的所有 sheet 名称列表
示例:
"往 test.xlsx 添加一个名为 成绩表 的 sheet" -> { file_path: "test.xlsx", data: '[{"姓名":"张三","成绩":90}]', sheet_name: "成绩表" }
错误处理:
Sheet 名称已存在: "Sheet "名称" 已存在。可用 ..."
文件不存在: "文件不存在: ..."
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | 已存在的 xlsx 文件路径 | |
| data | Yes | JSON 数据: 可以是对象数组或二维数组 | |
| sheet_name | Yes | 新 sheet 名称 (不能与已有 sheet 重名) |