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

网站建设属于什么科目seo是什么公司

网站建设属于什么科目,seo是什么公司,安徽网络营销,南京网络公司平台加油,新时代打工人! 工作需求,上个文章我们生成好的word,这次将生成好的excel表格数据,插入word中。需要准备好excle数据,然后插入到word中。 最后个需要,就是把这些生成好的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.hyszgw.com/news/452.html

相关文章:

  • 三大门户网站哪家做的最好求几个好看的关键词
  • 公司品牌的塑造网站建设百度助手官网
  • 网站建设原创长沙seo网络营销推广
  • 专业做网站关键词排名下掉微信搜索seo优化
  • 网站seo推广怎么做太原网站关键词推广
  • 凡客网站官网推广赚佣金的软件排名
  • 有新浪的域名怎么做网站seo网站内部优化方案
  • 苏州企业商务网站建设北京seo公司工作
  • 网站开发工作好找吗宁波seo软件
  • python做的大型网站百度 seo优化作用
  • 软件开发外包工作室厦门百度关键词seo收费
  • 华为网站建设策划书关于进一步优化 广州
  • 想学外贸从哪里入手怎样给自己的网站做优化
  • 网站定制开发报价单蜜雪冰城网络营销案例分析
  • 湖南移动网站建宣传广告
  • wordpress 写文章seo的中文含义是什么意思
  • 直销网站建设网站做推广的都是怎么推
  • wordpress怎么修改url百度seo培训班
  • 德州网站建设公司百度指数使用方法
  • 深圳网站设计 深圳信科百度收录网址提交
  • react做网站网站建设公司服务
  • 营销数据网站网站发帖推广平台
  • 潍坊视频类网站建设长沙关键词优化新行情报价
  • 北京做家教的的网站上海知名的seo推广咨询
  • 成都专业建站推广公司搜索引擎优化网站的网址
  • 从色彩度讨论如何建设一个网站.2023年度最火关键词
  • 打代码做网站的软件qq推广链接生成
  • 网站开发域名注册功能如何制作网址链接
  • 三水网站建设拼多多关键词排名查询软件
  • 网站设计哪家便宜企业培训课程开发