# excel-print-server
**Repository Path**: yanxin_2/excel-print-server
## Basic Information
- **Project Name**: excel-print-server
- **Description**: excel打印模版设计的服务端
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-02-09
- **Last Updated**: 2026-02-09
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Print Server
用于将 ExcelTable 的 HTML 字符串转换为 PDF 的 Express 服务器。
## 安装依赖
```bash
npm install
```
## 启动服务器
```bash
npm start
```
开发模式(自动重启):
```bash
npm run dev
```
服务器默认运行在 `http://localhost:3000`
## API 接口
### POST /api/print
将包含模板变量的 HTML 表格转换为 PDF。
**请求体:**
```json
{
"tableHtml": "
",
"data": {
"name": "张三",
"age": 25,
"user": {
"email": "zhangsan@example.com"
}
}
}
```
**响应:**
返回 PDF 文件流,Content-Type 为 `application/pdf`
**模板变量语法:**
- `$variable` - 简单变量
- `${variable}` - 带花括号的变量
- `$user.email` - 嵌套对象属性(使用点号分隔)
**示例:**
HTML 模板:
```html
| 姓名:$name |
年龄:${age} |
邮箱:$user.email |
```
数据:
```json
{
"name": "张三",
"age": 25,
"user": {
"email": "zhangsan@example.com"
}
}
```
替换后的结果:
```html
| 姓名:张三 |
年龄:25 |
邮箱:zhangsan@example.com |
```
### GET /health
健康检查接口,返回服务器状态。