当前位置: 首页 > news >正文

网站建设全网推广dw网页设计图片链接

网站建设全网推广,dw网页设计图片链接,网站开发外贸客户,小白怎么做网页加油#xff0c;新时代打工人#xff01; 工作需求#xff0c;上个文章我们生成好的word#xff0c;这次将生成好的excel表格数据#xff0c;插入word中。需要准备好excle数据#xff0c;然后插入到word中。 最后个需要#xff0c;就是把这些生成好的word文档转成pdf进行… 加油新时代打工人 工作需求上个文章我们生成好的word这次将生成好的excel表格数据插入word中。需要准备好excle数据然后插入到word中。 最后个需要就是把这些生成好的word文档转成pdf进行前端下载下来。 Java使用apache.poi生成word package com.wh.filedownload.controller;import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTableCell; import org.apache.poi.xwpf.usermodel.XWPFTableRow; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException;/*** author wh* date 2024年05月22日16:12* 将excel表格数据,导入现有的word模板中.*/ public class word2 {public static void main(String[] args) throws IOException, InvalidFormatException {String excelFilePath sample.xlsx;String wordFilePath output.docx;String tempWordFilePath tempWordFile.docx;FileInputStream excelFileInputStream new FileInputStream(new File(excelFilePath));Workbook workbook WorkbookFactory.create(excelFileInputStream);Sheet sheet workbook.getSheetAt(0); // 假设只处理第一个sheetFileInputStream wordFileInputStream new FileInputStream(new File(wordFilePath));XWPFDocument document new XWPFDocument(wordFileInputStream);int rowCount sheet.getLastRowNum();int colCount sheet.getRow(0).getLastCellNum(); // 假设第一行有最多的列// 创建Word中的表格XWPFTable table document.createTable(rowCount 1, colCount); // 1行是为了标题// 获取或创建表格的边框设置对象CTTblBorders tblBorders table.getCTTbl().getTblPr().getTblBorders();// 设置表格边框样式tblBorders.getTop().setVal(STBorder.SINGLE); // 上边框tblBorders.getLeft().setVal(STBorder.SINGLE); // 左边框tblBorders.getRight().setVal(STBorder.SINGLE); // 右边框tblBorders.getBottom().setVal(STBorder.SINGLE); // 下边框// 填充表格标题Row headerRow sheet.getRow(0);for (int i 0; i colCount; i) {XWPFTableCell cell table.getRow(0).getCell(i);cell.setText(headerRow.getCell(i).getStringCellValue());}// 填充表格数据for (int rowIndex 1; rowIndex rowCount; rowIndex) { // 从1开始跳过标题行Row dataRow sheet.getRow(rowIndex);if (dataRow null) continue; // 跳过空行XWPFTableRow tableRow table.getRow(rowIndex); // 对应的Word表格行for (int colIndex 0; colIndex colCount; colIndex) {Cell cell dataRow.getCell(colIndex);if (cell null) continue; // 如果单元格为空则跳过switch (cell.getCellType()) {case STRING:tableRow.getCell(colIndex).setText(cell.getStringCellValue());break;case NUMERIC:if (DateUtil.isCellDateFormatted(cell)) {tableRow.getCell(colIndex).setText(cell.getLocalDateTimeCellValue().toString());} else {tableRow.getCell(colIndex).setText(String.valueOf(cell.getNumericCellValue()));}break;// 可以继续添加对其他类型的处理}}}wordFileInputStream.close();FileOutputStream out new FileOutputStream(tempWordFilePath);document.write(out);out.close();document.close();workbook.close();excelFileInputStream.close();// 这里可以选择将tempWordFilePath移动或重命名为wordFilePath以覆盖原文件// 注意这一步骤会永久改变原Word文档File srcFile new File(tempWordFilePath);File destFile new File(wordFilePath);srcFile.renameTo(destFile);System.out.println(Excel content has been appended to the Word document.);}}运行结果。
http://www.pierceye.com/news/868820/

相关文章:

  • vps服务器购买网站自己做的网站可以买东西吗
  • 必应网站建设深圳设计大厦
  • 如何禁止ip访问网站常州网站建设公司推荐
  • 大型论坛网站建设设计公司
  • 河北网诚网站建设企业采购平台有哪几个知名
  • wordpress 站点迁移做跨境电商哪个平台好
  • 想建设一个网站 一般多少钱营口软件开发
  • 杭州科技公司网站建设百度的网站建设代码
  • 网站怎么做收入广州番禺招聘网最新招聘信息
  • 网站设计的毕业设计剧院网站建设
  • 微商城网站建设案例做带支付功能的网站
  • 响应式网站开发公司义务 网站建设
  • 网站前台和后台对接北京app开发公司排名
  • 网站开发工具的在南海建设工程交易中心网站
  • 广西建设厅官方网站文件通知wordpress默认字体颜色
  • 品牌网站建设联系方式网页截图快捷键是哪个键
  • 现在网站一般都是什么语言做的软件著作权证书
  • html5在网站建设中的本地环境wordpress修改php.ini
  • wap电影网站建设宁波谷歌seo推广
  • 中国建设银官方网站WordPress国内开发主题
  • 芜湖seo网站优化域名邮箱免费注册
  • 做宠物网站需要实现什么功能成都建工网站
  • jsp购物网站开发 论文海口澄迈县建设局网站
  • 单页销售网站制作制作花都区网站建设
  • 如何建立自己的购物网站discuz手机模板
  • 网站被刷流量怎么办wordpress fold主题
  • 做的新网站网上搜不到临沂免费做网站
  • 高端大气的网站制作建筑人才网下载
  • 如何快速提升网站关键词排名综合服务平台一站式服务平台网站开发
  • 阿土伯 是做网站的吗建设厅国网查询网站