1 Star 0 Fork 0

beimang233/apache-learn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
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-filesword-templates目录
  • 使用图片功能时,确保提供有效的图片路径
  • 使用模板功能时,确保在word-templates目录中有对应的模板文件

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/beimang233/apache-learn.git
git@gitee.com:beimang233/apache-learn.git
beimang233
apache-learn
apache-learn
master

搜索帮助