# apache-learn **Repository Path**: beimang233/apache-learn ## Basic Information - **Project Name**: apache-learn - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-04 - **Last Updated**: 2025-07-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring Boot Word文档处理项目 这是一个基于Spring Boot的Word文档处理项目,使用Apache POI库来创建、读取和修改Word文档。 ## 功能特点 - 创建简单的Word文档 - 读取Word文档内容 - 创建包含表格的Word文档 - 创建包含图片的Word文档 - 基于模板创建Word文档(替换占位符) ## 技术栈 - Spring Boot 3.3.3 - Apache POI 5.2.5 - Java 17 ## 项目结构 ``` my-apache/ ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── example/ │ │ │ ├── Main.java # 应用程序入口 │ │ │ ├── controller/ │ │ │ │ ├── WordController.java # 基本Word操作控制器 │ │ │ │ └── AdvancedWordController.java # 高级Word操作控制器 │ │ │ └── service/ │ │ │ ├── WordService.java # 基本Word操作服务 │ │ │ └── AdvancedWordService.java # 高级Word操作服务 │ │ └── resources/ │ └── test/ ├── word-files/ # 生成的Word文档存储目录 ├── word-templates/ # Word文档模板目录 └── pom.xml # Maven配置文件 ``` ## API接口 ### 基本Word操作 - `POST /api/word/create` - 创建简单Word文档 - 参数: fileName, title, content - `GET /api/word/read` - 读取Word文档内容 - 参数: fileName ### 高级Word操作 - `POST /api/word/advanced/create-table` - 创建包含表格的Word文档 - 参数: fileName, title - `POST /api/word/advanced/create-with-image` - 创建包含图片的Word文档 - 参数: fileName, title, content, imagePath - `POST /api/word/advanced/create-from-template` - 基于模板创建Word文档 - 参数: templateName, outputName ### 模板操作 - `POST /api/word/template/generate` - 生成示例Word模板文件 - 参数: templateName ## 使用示例 ### 创建简单Word文档 ``` POST http://localhost:8080/api/word/create?fileName=test&title=测试文档&content=这是一个测试文档内容 ``` ### 创建包含表格的Word文档 ``` POST http://localhost:8080/api/word/advanced/create-table?fileName=table-test&title=表格测试文档 ``` ### 生成Word模板文件 ``` POST http://localhost:8080/api/word/template/generate?templateName=sample-template ``` ### 基于模板创建Word文档 ``` POST http://localhost:8080/api/word/advanced/create-from-template?templateName=sample-template&outputName=template-output ``` ## 注意事项 - 确保在运行前创建`word-files`和`word-templates`目录 - 使用图片功能时,确保提供有效的图片路径 - 使用模板功能时,确保在`word-templates`目录中有对应的模板文件