Skip to content

Commit 4f1d6f2

Browse files
author
2lipan
committed
新增Excel文件,实现数据写入和下载文件功能
1 parent 0a5ef84 commit 4f1d6f2

4 files changed

Lines changed: 67 additions & 0 deletions

File tree

4.74 KB
Binary file not shown.

tools/tool_data_to_excel/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# 数据写入 EXCEL 工具
2+
3+
支持将数据写入 EXCEL 文件并提供下载链接。
4+
5+
## 1 参数说明
6+
7+
### 1.1 安装依赖
8+
进到 maxkb 容器里,安装 requests 库即可
9+
10+
```linux
11+
pip install openpyxl -i https://pypi.tuna.tsinghua.edu.cn/simple
12+
pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple
13+
```
14+
15+
### 1.2 启动参数
16+
17+
| 参数名 | 类型 | 说明 |
18+
| ---------------- | ---- | ------------|
19+
| `base_url` | str | MaxKB 地址 |
20+
| `api_key` | str | 用户的api-key|
21+
22+
### 1.3 输入参数
23+
24+
| 参数名 | 类型 | 说明 |
25+
| -------------- | ---- | ------------------------- |
26+
| `data_list` | array | 要写入excel的数据 |
27+
| `headers` | array | excel的表头 |
28+
| `sheet_name` | str | sheet页名称 |
29+
| `excel_name` | str | excel文件名称 |
30+
31+
#### 填写示例:
32+
33+
`headers`: excel的表头,如'["状态", "记忆","内容","标签","更新时间","响应","错误信息"]'
34+
35+
`data_list`: 要写入excel的数据,如
36+
```
37+
[
38+
{
39+
"status": "未完成",
40+
"memory": "test_0001",
41+
"content": "我是AI智能体",
42+
"tags": "AI,智能体",
43+
"update_time": "20260304",
44+
"response": "AI真牛",
45+
"error_msg": "无"
46+
}
47+
]
48+
```
49+
50+
`sheet_name`:sheet 页名称,如"记录状态信息表"
51+
52+
`excel_name`:excel 文件名称,如 "test" 或者 "test.xlsx"
53+
54+
## 2 响应
55+
56+
返回包含下载链接的 HTML 字符串,如
57+
58+
```
59+
<html_rander>
60+
<a href="..." download="...">文件名.xlsx</a>
61+
</html_rander>
62+
```

tools/tool_data_to_excel/data.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: 数据写入 EXCEL
2+
tags:
3+
- 内容处理
4+
title: 支持将数据写入 EXCEL 文件并提供下载链接。
5+
description: 支持将数据写入 EXCEL 文件并提供下载链接。

tools/tool_data_to_excel/logo.png

30.7 KB
Loading

0 commit comments

Comments
 (0)