将结构化文本内容生成为Excel表格(.xlsx)的工具。支持解析用户提供的各种结构化文本(表格、列表、键值对、CSV、Markdown表格、JSON等),自动识别表头和数据行,生成格式规整的Excel文件。支持多sheet、合并单元格、样式设置、冻结窗格、自动筛选、条件格式、数据验证、图表生成等全部功能。当用户提到以下场景时触发:(1) 需要将文本/数据/内容转换为Excel/表格/xlsx文件 (2) 需要生成Excel表格 (3) 需要创建电子表格 (4) 提供了结构化数据并要求输出为Excel (5) 要求整理数据到表格中 (6) 需要把信息做成表格导出。关键词:Excel、表格、xlsx、电子表格、导出表格、生成表格、做成表格、转成表格、整理成表格。
将结构化文本转换为格式规整的Excel文件。
Analyze user-provided structured text. Supported input formats:
| col1 | col2 |)Identify: headers, data rows, data types per column, and any special formatting requests.
Ask the user for the save path. Suggest a reasonable default filename based on the content (e.g. ~/Desktop/sales_data.xlsx).
Construct a JSON config object following the schema in references/config_schema.md.
Minimal example:
{
"sheets": [{
"name": "Sheet1",
"headers": ["Name", "Age", "City"],
"data": [
["Alice", 30, "Beijing"],
["Bob", 25, "Shanghai"]
]
}]
}
Full-featured example with styles, charts, and validation:
{
"sheets": [{
"name": "Sales",
"title_row": {"text": "Q1 Sales Report", "style": {"font": {"bold": true, "size": 16}}},
"headers": ["Month", "Revenue", "Growth"],
"data": [
["January", 50000, 0.12],
["February", 62000, 0.24],
["March", 58000, 0.16]
],
"column_types": ["text", "currency_cny", "percent"],
"freeze_pane": "A2",
"auto_filter": true,
"charts": [{
"type": "bar",
"title": "Monthly Revenue",
"x_column": 1,
"y_columns": [2],
"position": "E2"
}],
"conditional_formats": [{
"type": "color_scale",
"range": "B2:B4"
}]
}]
}
python3 scripts/generate_excel.py <config.json> <output_path>The script applies professional defaults automatically:
Override any default by specifying header_style, data_style, or per-cell styles in the config.
sheets arraymerge_cells with range strings or row/col objectsfreeze_pane to e.g. "A2" to freeze header rowauto_filter: true to enable dropdown filterspercent, currency_cny, currency_usd, date) or custom Excel format stringsSee full schema: references/config_schema.md