Java poi导出word文件

2023-11-02

Java在导出word文件时主要对表格中内容垂直居中处理做以记录方便后续碰到类似问题解决。

maven pom.xml中添加poi依赖

<!-- word、excel工具 -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
     <poi.version>4.1.2</poi.version>
</dependency>

下载后查看依赖是否成功

 此时当在wordutil.java类中  CTPageSz 报红是因为ooxml-shemas版本不对需要另外下载1.3版本然后添加到本项目依赖中即可

下载ooxml-shemas1.4版本的依赖pom;注意有些1.3版本太低了,换成1.4版本即可。

<!-- CTPageSz 横向纵向设置 -->
 <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>ooxml-schemas</artifactId>
     <version>1.4</version>
 </dependency>

poi整个依赖如下:

 

 controller层

package cn.umidata.supervision.dataeye.controller;

import cn.umidata.supervision.biz.service.ReportExWordService;
import cn.umidata.supervision.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Date;

/**
 * @BelongsProject: supervision
 * @BelongsPackage: cn.umidata.supervision.dataeye.controller
 * @Author: zhanghui
 * @CreateTime: 2023-04-21  14:29
 * @Description: 报表
 * @Version: 1.0
 */
@Api(tags = "报表导出word")
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportExWordService reportExWordService;

//    @ApiOperation(value = "导出监管报告",notes = "导出监管报告")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "dwmc",value = "单位名称",required = true),
//            @ApiImplicitParam(name = "kqmc",value = "库区名称",required = true)
//    })
//    @GetMapping("/exportJG")
//    public AjaxResult exportJG(String dwmc,String kqmc){
//        return reportExWordService.exportJG(dwmc,kqmc);
//    }
    @ApiOperation(value = "导出监管报告",notes = "导出监管报告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dwmc",value = "单位名称",required = true),
            @ApiImplicitParam(name = "kqmc",value = "库区名称",required = true)
    })
    @GetMapping("/exportJG")
    public void exportJG(HttpServletRequest request,
                               HttpServletResponse response, String dwmc, String kqmc) throws IOException {
        XWPFDocument doc = reportExWordService.exportJG(request, response, dwmc,kqmc);
        String fileName = dwmc+kqmc+"监管" + System.currentTimeMillis() + ".docx";
        response.setCharacterEncoding("UTF-8");
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName,"UTF-8"));
        response.setContentType("application/x-msdownload");
        OutputStream out = response.getOutputStream();
        doc.write(out);
    }

    @ApiOperation(value = "导出质量报告",notes = "导出质量报告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dwmc",value = "单位名称",required = true),
            @ApiImplicitParam(name = "kqmc",value = "库区名称",required = true),
            @ApiImplicitParam(name = "datetime",value = "时间",required = true),
    })
    @GetMapping("/exportZL")
    public void exportZL(HttpServletRequest request,
                         HttpServletResponse response, String dwmc, String kqmc, String datetime) throws IOException {
        XWPFDocument doc = reportExWordService.exportZL(request, response, dwmc,kqmc,datetime);
        String fileName = dwmc+kqmc+"质量" + System.currentTimeMillis() + ".docx";
        response.setCharacterEncoding("UTF-8");
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName,"UTF-8"));
        response.setContentType("application/x-msdownload");
        OutputStream out = response.getOutputStream();
        doc.write(out);
    }

    @ApiOperation(value = "导出临时word文件",notes = "导出临时word文件")
    @GetMapping("/exportTmp")
    public void exportTmp(HttpServletRequest request,HttpServletResponse response) throws IOException {
        XWPFDocument doc = reportExWordService.exportTmp(request,response);
        String fileName = "元始天尊" + System.currentTimeMillis() + ".docx";
        response.setCharacterEncoding("UTF-8");
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName,"UTF-8"));
        response.setContentType("application/x-msdownload");
        OutputStream out = response.getOutputStream();
        doc.write(out);
    }
}

Service接口

package cn.umidata.supervision.biz.service;

import cn.umidata.supervision.common.core.domain.AjaxResult;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;

public interface ReportExWordService {
    /**
     * @description: 导出监管报告
     * @author: zhanghui
     * @date: 2023/4/27 0027 上午 10:00
     * @param: [request, response, dwmc, kqmc]
     * @return: org.apache.poi.xwpf.usermodel.XWPFDocument
     **/
    XWPFDocument exportJG(HttpServletRequest request, HttpServletResponse response, String dwmc, String kqmc);
    /**
     * @description: 导出质量报告
     * @author: zhanghui
     * @date: 2023/4/27 0027 上午 10:00
     * @param: [request, response, dwmc, kqmc, datetime]
     * @return: org.apache.poi.xwpf.usermodel.XWPFDocument
     **/
    XWPFDocument exportZL(HttpServletRequest request, HttpServletResponse response, String dwmc, String kqmc, String datetime);
    /**
     * @description: 导出临时word文件
     * @author: zhanghui
     * @date: 2023/4/27 0027 上午 10:00
     * @param: [request, response]
     * @return: org.apache.poi.xwpf.usermodel.XWPFDocument
     **/
    XWPFDocument exportTmp(HttpServletRequest request, HttpServletResponse response);


}

service业务层

package cn.umidata.supervision.biz.service.impl;


import cn.umidata.supervision.biz.service.ReportExWordService;
import cn.umidata.supervision.common.utils.poi.WordUtil;
import org.apache.poi.xwpf.usermodel.*;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @BelongsProject: supervision
 * @BelongsPackage: cn.umidata.supervision.biz.service.impl
 * @Author: zhanghui
 * @CreateTime: 2023-04-21  14:44
 * @Description: 导出word 报表业务处理
 * @Version: 1.0
 */
@Service
public class ReportExWordServiceImpl implements ReportExWordService {

    /**
     * @description: 导出监管报表word
     * @author: zhanghui
     * @date: 2023/4/21 0021 下午 2:55
     * @param: [dwmc, kqmc]
     * @return: cn.umidata.supervision.common.core.domain.AjaxResult
     **/
    @Override
    public XWPFDocument exportJG(HttpServletRequest request, HttpServletResponse response, String dwmc, String kqmc) {
        Date date = new Date();
        //SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //String time = simpleDateFormat.format(date);
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy年MM月dd日");
        SimpleDateFormat format2 = new SimpleDateFormat("yyyy年度M月");
        SimpleDateFormat format3 = new SimpleDateFormat("yyyyMMddHHmmss");
        String ndTime = format2.format(date);
        String tjTime = format1.format(date);
        String bhTime = format3.format(date);

        XWPFDocument doc = new XWPFDocument();
        WordUtil.setH(doc);
        WordUtil.setParagraph(doc,ndTime+"份"+kqmc+"储备粮监管平台储备情况监管报告","宋体",22,100,true,ParagraphAlignment.CENTER);
        WordUtil.setParagraph(doc,"编号:V"+bhTime+"                               "+"统计时间:"+tjTime,"宋体",12,20,true,ParagraphAlignment.CENTER);
        WordUtil.setTitleText(doc,"一、粮食储备整体情况",20,true,false);
        WordUtil.setTable(doc);
        WordUtil.setTitleText(doc,"二、各库区粮食储备详细概况",20,true,false);
        WordUtil.setTableKQ(doc);
        WordUtil.setTitleText(doc,"三、风险预警概况",20,true,false);
        WordUtil.setTableFX(doc);


        return doc;
    }

    /**
     * @description: 质量报告
     * @author: zhanghui
     * @date: 2023/4/24 0024 下午 3:41
     * @param: [request, response, dwmc, kqmc, datetime]
     * @return: org.apache.poi.xwpf.usermodel.XWPFDocument
     **/
    @Override
    public XWPFDocument exportZL(HttpServletRequest request, HttpServletResponse response, String dwmc, String kqmc,String datetime) {
        Date date = new Date();
        SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat format3 = new SimpleDateFormat("yyyyMMddHHmmss");
        String bhTime = format3.format(date);
        String bgTime = format1.format(date);
        XWPFDocument doc = new XWPFDocument();
        WordUtil.setH(doc);
        WordUtil.setParagraph(doc,"陕西省省级储备粮监管信息化平台数据质量报告","宋体",22,100,true,ParagraphAlignment.CENTER);
        WordUtil.setParagraph(doc,"编号:V"+bhTime+"                               "+"统计时间:"+bgTime,"宋体",12,20,true,ParagraphAlignment.CENTER);
        WordUtil.setTableZL(doc,datetime,dwmc);
        XWPFParagraph paragraph = doc.createParagraph();
        XWPFRun run = paragraph.createRun();
        run.setText("注:1.上传库存指粮食库存接口中粮食性质为省、市、县三级储备的计价数量字段合计(不含孤岛数据);2.实际库存取自各省统计直报系统报送数据;3.实际业务相符率指上传库存/实际库存;4.修正业务相符率指上传库存/实际库存,当业务相符率<=1时,取原值;业务相符率>1时,2-得数;业务相符率>=2时,取0。5.数据上传总量指调用国家平台接口的数据条数合计;6.入库数据总量指上传数据总量通过拦截评测并入库保存的数据;7.问题总数指入库数据中存在的问题数量,一条记录可能有多个问题;8.问题记录数指存在问题的记录条数,问题记录数<=问题总数;9.非空字段总数指所有接口不为空字段的数量合计;10.字段总量指所有接口字段的数量合计;11.接口开通率指已连通的接口个数/所有接口个数;12.通过率指入库数据总量/数据上传总量;13.完整率指上传数据非空字段总数/上传数据的字段总数;14.合格率指∑(各接口合格率*接口系数)。其中,各接口合格率=问题数据条数/入库数据总量;15.评分标准(暂定)。修正业务相符率*(接口开通率*10%+数据通过率*10%+数据完整率*20%+数据合格率*60%),得分精确到小数点后2位。");

        return doc;
    }

/**
     * @description: 导出临时word文件
     * @author: zhanghui
     * @date: 2023/4/26 0026 下午 4:02
     * @param: [request, response]
     * @return: org.apache.poi.xwpf.usermodel.XWPFDocument
     **/
    @Override
    public XWPFDocument exportTmp(HttpServletRequest request, HttpServletResponse response) {
        XWPFDocument doc = new XWPFDocument();
        WordUtil.setParagraph(doc,"十里平湖霜满天","宋体",22,100,true,ParagraphAlignment.CENTER);
        WordUtil.creataTable(doc);
        return doc;
    }

}

WordUtil 工具类

package cn.umidata.supervision.common.utils.poi;

import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @BelongsProject: supervision
 * @BelongsPackage: cn.umidata.supervision.common.utils.poi
 * @Author: zhanghui
 * @CreateTime: 2023-04-21  14:57
 * @Description: word相关处理
 * @Version: 1.0
 */
public class WordUtil {


    private static final Logger log = LoggerFactory.getLogger(WordUtil.class);
    //创建默认的页脚(该页脚主要只居中显示页码)
    public static void createDefaultFooter(XWPFDocument docx) {
        CTSectPr sectPr = docx.getDocument().getBody().addNewSectPr();
        XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(docx, sectPr);
        XWPFFooter footer = headerFooterPolicy.createFooter(STHdrFtr.DEFAULT);
        XWPFParagraph paragraph = footer.getParagraphArray(0);
        paragraph.setAlignment(ParagraphAlignment.CENTER);
        paragraph.setVerticalAlignment(TextAlignment.CENTER);
        CTTabStop tabStop = paragraph.getCTP().getPPr().addNewTabs().addNewTab();
        tabStop.setVal(STTabJc.CENTER);
        XWPFRun run = paragraph.createRun();
        run.addTab();
        run = paragraph.createRun();
        run.setText("第");
        run = paragraph.createRun();
        CTFldChar fldChar = run.getCTR().addNewFldChar();
        fldChar.setFldCharType(STFldCharType.Enum.forString("begin"));
        run = paragraph.createRun();
        CTText ctText = run.getCTR().addNewInstrText();
        ctText.setStringValue("PAGE  \\* MERGEFORMAT");
        ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve"));
        fldChar = run.getCTR().addNewFldChar();
        fldChar.setFldCharType(STFldCharType.Enum.forString("end"));
        run = paragraph.createRun();
        run.setText("页/共");
        run = paragraph.createRun();
        fldChar = run.getCTR().addNewFldChar();
        fldChar.setFldCharType(STFldCharType.Enum.forString("begin"));
        run = paragraph.createRun();
        ctText = run.getCTR().addNewInstrText();
        ctText.setStringValue("NUMPAGES  \\* MERGEFORMAT ");
        ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve"));
        fldChar = run.getCTR().addNewFldChar();
        fldChar.setFldCharType(STFldCharType.Enum.forString("end"));
        run = paragraph.createRun();
        run.setText("页");
    }

    /**
     * 设置表头内容
     *
     * @param cell
     * @param text
     * @param width
     * @param fontFamily
     * @param fontSize
     * @param bold
     */
    public static void setCellText(XWPFTableCell cell, String text, int width, String fontFamily, int fontSize, boolean bold) {
        XWPFParagraph paragraph = cell.getParagraphs().get(0);
        XWPFRun run = paragraph.createRun();
        run.setFontFamily(fontFamily);
        run.setFontSize(fontSize);
        run.setBold(bold);
        run.setText(text);
        CTTc cttc = cell.getCTTc();
        CTTcPr cellPr = cttc.addNewTcPr();
        cellPr.addNewTcW().setW(BigInteger.valueOf(width));
        cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
        CTTcPr ctPr = cttc.addNewTcPr();
        ctPr.addNewVAlign().setVal(STVerticalJc.CENTER);
        cttc.getPList().get(0).addNewPPr().addNewJc().setVal(STJc.CENTER);
    }
    /**
     * 设置页边距
     *
     * @param doc
     * @param left
     * @param right
     * @param top
     * @param bottom
     */
//    public static void setMargin(XWPFDocument doc, int left, int right, int top, int bottom) {
//        CTSectPr sectPr = doc.getDocument().getBody().addNewSectPr();
//        CTPageMar pageMar = sectPr.addNewPgMar();
//        pageMar.setLeft(BigInteger.valueOf(left));
//        pageMar.setRight(BigInteger.valueOf(right));
//        pageMar.setTop(BigInteger.valueOf(top));
//        pageMar.setBottom(BigInteger.valueOf(bottom));
//    }

    /**
     * 设置段落文本
     *
     * @param doc
     * @param text
     * @param fontFamily
     * @param fontSize
     * @param textPosition
     * @param bold
     * @param paragraphAlignment
     */
    public static void setParagraph(XWPFDocument doc,
                                    String text,
                                    String fontFamily,
                                    int fontSize,
                                    int textPosition,
                                    boolean bold,
                                    ParagraphAlignment paragraphAlignment) {
        XWPFParagraph xp = doc.createParagraph();
        xp.setSpacingBefore(0);
        XWPFRun r1 = xp.createRun();
        r1.setText(text);
        r1.setFontFamily(fontFamily);
        r1.setFontSize(fontSize);
        r1.setTextPosition(textPosition);
        r1.setBold(bold);
        xp.setAlignment(paragraphAlignment);
    }

    /**
     * @description:  设置为横向
     * @author: zhanghui
     * @date: 2023/4/23 0023 上午 11:34
     * @param: [doc]
     * @return: void
     **/
    public static void setH(XWPFDocument doc){
        CTSectPr sectPr = doc.getDocument().getBody().addNewSectPr();
        CTPageSz pgsz = sectPr.isSetPgSz() ? sectPr.getPgSz() : sectPr.addNewPgSz();
        //设置横板
        pgsz.setW(BigInteger.valueOf(15840));
        pgsz.setH(BigInteger.valueOf(11907));
        pgsz.setOrient(STPageOrientation.LANDSCAPE);

    }

    /**
     * @description:  设置表格内容
     * @author: zhanghui
     * @date: 2023/4/23 0023 下午 3:16
     * @param: [xdoc, text, fontSize, isBold, isCenter]
     * @return: void
     **/
    public static void setTitleText(XWPFDocument xdoc, String text, Integer fontSize, boolean isBold,boolean isCenter) {
        XWPFParagraph xp = xdoc.createParagraph();
        XWPFRun r1 = xp.createRun();
        r1.setText(text);
        r1.setFontFamily("宋体");
        if(fontSize != null){
            r1.setFontSize(fontSize);
        }
        if(isBold){
            r1.setBold(true);
        }
        if(isCenter){
            xp.setAlignment(ParagraphAlignment.CENTER);
        }
    }

/**
 * @description: 创建表一
 * @author: zhanghui
 * @date: 2023/4/24 0024 上午 11:27
 * @param: [xdoc]
 * @return: void
 **/
  public static void setTable(XWPFDocument xdoc,JgCbzt jgCbzt){
      XWPFTable xTable = xdoc.createTable();//创建表格
      CTTblPr tblPr =xTable.getCTTbl().addNewTblPr(); //内容居中
      tblPr.addNewJc().setVal(STJc.CENTER);
      //兼容wps
      CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW(); //列宽自动分割
      tblWidth.setW(new BigInteger("1036000"));//总长度
      tblWidth.setType(STTblWidth.AUTO);
      xTable.getRow(0).setHeight(30);//高度
      setBodyTextTmp(xTable.getRow(0).getCell(0), "储备概况", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "监管储备单位(家)", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), 3600, null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "监管库区(个)", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), 3600, null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "", null,true,true,2500);
      setBodyTextTmp(xTable.getRow(0).addNewTableCell(), "", null,true,true,2500);
      XWPFTableRow rowTitle2 = xTable.createRow();//第二行表头
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle2.getCell(0), "", null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(1), "仓房(个)", null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(3), "廒间(个)", null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(4), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(5), "货位(个)", null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(6), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(7), "油罐(个)", null,false,true,2500);
      setBodyTextTmp(rowTitle2.getCell(8), 3600, null,false,true,2500);
      XWPFTableRow rowTitle3 = xTable.createRow();//第三行表头
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle3.getCell(0), "", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(1), "总仓容(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(3), "", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(4), "", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(5), "已用仓容(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(6), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(7), "未用仓容(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle3.getCell(8), 3600, null,false,true,2500);
      XWPFTableRow rowTitle4 = xTable.createRow();
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle4.getCell(0), "粮食数量", null,true,true,2500);
      setBodyTextTmp(rowTitle4.getCell(1), "监管粮食储备总量(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(3), "", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(4), "", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(5), "", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(6), "", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(7), "", null,false,true,2500);
      setBodyTextTmp(rowTitle4.getCell(8), "", null,false,true,2500);
      XWPFTableRow rowTitle5 = xTable.createRow();
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle5.getCell(0), "", null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(1), "一小麦(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(3), "二小麦(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(4), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(5), "玉米(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(6), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(7), "稻谷(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle5.getCell(8), 3600, null,false,true,2500);
      XWPFTableRow rowTitle6 = xTable.createRow();
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle6.getCell(0), "", null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(1), "省级储备粮(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(3), "市级储备粮(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(4), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(5), "商品粮(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(6), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(7), "", null,false,true,2500);
      setBodyTextTmp(rowTitle6.getCell(8), "", null,false,true,2500);
      XWPFTableRow rowTitle7 = xTable.createRow();
      xTable.getRow(0).setHeight(30);
      setBodyTextTmp(rowTitle7.getCell(0), "", null,false,true,2500);
      setBodyTextTmp(rowTitle7.getCell(1), "2023年(万吨)", null,false,true,2500);
      setBodyTextTmp(rowTitle7.getCell(2), 3600, null,false,true,2500);
      setBodyTextTmp(rowTitle7.getCell(3), "2022年(万吨
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Java poi导出word文件 的相关文章

随机推荐

  • SEO百度搜索引擎优化网站排名

    目录 seo优化 介绍seo是什么 网站更新 网站排名在21世纪的意义 网站为电商引流 百度算法规则 排名流程 seo策略 规则 学会在线球里玩 单页面收录显示 必要条件 链接数量 日志统计 及时优化seo策略 降低识别难度 收录越多排名就
  • Matlab:*.txt转换为*.mat

    在许多应用中 将其他仿真软件输出的数据导入Matlab中应用 Matlab导入的数据文件格式为 mat 而其他仿真输出数据格式为 txt 因此要在使用之前将 txt格式转换为 mat格式 语句如下 Load txt 为文件存储路径及文件名
  • 环保产业发展前景:“智能化”为绿色环保注入新动能

    摘要 随着我国环境治理要求的日益严格 环保设备市场需求巨大 产业持续快速增长 在智慧产业快速发展的同时 具备浓厚 云 色彩的环保设备在环境治理应用体系中将更有优势 智能化 数据化应用将会智慧环保 未来环保设备行业市场发展前景巨大 图绿色 智
  • 鼓励师加成太刺激了,鼻血喷了半斤,代码不一会儿就写完了...

    本文原创公众号 不会笑青年 授权转载请联系微信 laughyouth369 授权后 请在原创发表48小时后转载 我知道你在看
  • STM32F103ZET6【标准库】----- 04串口5的IO口收发数据实验测试

    链接 串口1的两组IO口收发数据实验 链接 串口2的两组IO口收发数据实验 链接 串口3的三组IO口收发数据实验 链接 串口4的一组IO口收发数据实验 一 硬件介绍 本次实验用到的单片机是STM32F103ZET6 正点原子战舰开发板 用到
  • Linux 网桥支持LLDP 透传的解决方法

    inux 虚拟网桥默认会悄悄地删除LLDP消息 发送到LLDP Multicast地址01 80 C2 00 00 0E 和01 80 C2 00 00 xx范围内的其他控制帧 原因可以在802 1AB标准中找到 该标准规定 the des
  • Window 通过cmd查看端口占用、相应进程、杀死进程

    一 查看所有进程占用的端口 在开始 运行 cmd 输入 netstat ano 可以查看所有进程 二 查看占用指定端口的程序 当你在用IIS发布程序时 经常会遇到端口80被占用的情况 我们想知道是哪个程序或进程占用了端口 可以用该命令 ne
  • java——为什么重写hashCode还需要重写equals

    hashCode与equals方法的作用其实一样 在java里面我们都是用它们来比较两个对象是否一致 那为和我们还需要使用hashCode 这里其实使用hashCode是为了提高效率 采取重写hashcode方法 先进行hashcode比较
  • 中学计算机课小课题,中学信息技术课题题目

    中学信息技术课题题目 分类 课题研究 发表时间 2019 04 19 10 27 信息技术是主要用于管理和处理信息所采用的各种技术的总称 在中学信息技术教学过程中 会遇到一些难以解决的问题 成为我们研究课题的选择对象范围 当然确定研究选题
  • 【mysql】日常遇到的问题解决

    目录 MySQL 删除数据库报错 1010 Error dropping database can t rmdir ERR 1452 Cannot add or update a child row a foreign key constr
  • Java常用API(十)——多线程基础

    多线程 允许 同时 执行多段代码 实际上多线程是并发运行的 每段代码都是走走停停的 CPU会在这些线程间快速切换 保证每段代码都有进度 从而感官上是同时运行 线程的创建 第一种创建方式 定义一个线程类并继承线程Thread 然后重写run方
  • SSH概述

    ssh是web开发中常见的一种框架 s struts s spring h hibernate 其中struts在框架中充当控制器 实现MVC 主要用来处理用户的请求 和跳转页面 使项目结构清晰 开发者只需要关注业务逻辑的实现即可 spri
  • windows DiskPart 磁盘分区命令工具参考

    DiskPart Windows 7 Disk Administration Partition a disk This page documents the Windows 7 2008 version of Diskpart an ea
  • 基于mbedtls的AES加密(C/C++)

    环境 操作系统 WSL2 Ubuntu22 04 加密库 mbedtls Base64 在线AES计算网站 SSLeye 代码中需要用到mbedtls和Base64 可以根据上述链接获取 简介 高级加密标准 Advanced Encrypt
  • !windows11

    啊啊啊 win11来了 似乎是泄漏版 晚上在图书馆看到的 后来回宿舍一看正好有个群里正在讨论此事 就试着安装了一下 还挺顺利 下面是几张美图
  • 终于,在Excel里也能直接写python了

    之前在处理数据的时候 最开始都是在excel里处理 后来当数据量上了一个级别后就用python导入excel文件接着处理了 很多人会说 excel有自带VBA语言 可以用那个来处理呀 不好意思 VBA不仅处理数据速度慢而且还非常麻烦 但是
  • 【51单片机实验笔记】前篇(三) 模块功能封装汇总(持续更新)

    文章目录 通用函数 public h public c 延时函数 delay h delay c LED模块 数码管模块 smg h smg c LED点阵模块 独立按键模块 矩阵按键模块 外部中断模块 定时器模块 串口通讯模块 ADC模块
  • 独家

    作者 宋莹 本文长度为10427字 建议阅读20 分钟 本文为你介绍数据挖掘的知识及应用 引言 最近笔者学到了一个新词 叫做 认知折叠 就是将复杂的事物包装成最简单的样子 让大家不用关心里面的细节就能方便使用 作为数据科学领域从业者 我们所
  • Jupyter notebook从电脑本地读取csv文件

    在菜单中打开Anaconda Prompt 然后输入 jupyter notebook generate config 打开输出的路径的配置文件 找到 c NotebookApp notebook dir 然后将 去掉 并且在 中写入想要存
  • Java poi导出word文件

    Java在导出word文件时主要对表格中内容垂直居中处理做以记录方便后续碰到类似问题解决 maven pom xml中添加poi依赖