# office-tool **Repository Path**: wang-hai-cheng/office-tool ## Basic Information - **Project Name**: office-tool - **Description**: office工具箱 根据模板导出列表数据/图片数据 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-28 - **Last Updated**: 2025-10-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # office-tool #### 介绍 基于poi和itexpdf封装的office相关操作工具类,欢迎提交代码,java CTO交流群:830841208 #### 软件功能说明 支持word,excel, pdf, 图片等处理 word:模板字符替换,图片填充替换 excel:模板字符替换 pdf:word转pdf,pdf转图片 #### 安装教程 1. 安装到本地: mvn install 2. 添加maven依赖 ``` wang-hai-cheng office-tool 1.0-SNAPSHOT ``` #### 使用说明 1. 参见demo:路径 src/test/java/com/demo 2. 文件在 根目录/file #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request demo ```` @Test public void excelTest() throws IOException { //以下所有的key都是模板中的变量名 String property = System.getProperty("user.dir"); HashMap map = new HashMap<>(); //导出普通key,value型数据 map.put("${name}", "bug"); map.put("${age}", 10); map.put("${price}", new BigDecimal("10.0100")); map.put("${now}", LocalDateTime.now()); map.put("${date}", new Date()); ArrayList> list = new ArrayList<>(); for (int i = 0; i < 10; i++) { ArrayList strings = new ArrayList<>(); strings.add("b" + i); strings.add("u" + i); strings.add("g" + i); list.add(strings); } //导出列表型数据 map.put("${list}", list); //导出图片数据 map.put("${pic}", FileUtil.getFile(property + "/file/pic.jpg")); Workbook workbook = ExcelUtil.create(property + "/file/模板文件.xlsx"); //替换变量数据 ExcelUtil.replace(workbook, map); ExcelUtil.write(workbook, property + "/temp/输出文件.xlsx"); } ````