1.表格示例
2.pom文件使用
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.0</version>
</dependency>
2.代码
public void export(Dto dto, HttpServletResponse response) throws Exception {
try {
XWPFDocument xdoc = new XWPFDocument();//创建xdoc
XWPFParagraph xpara = xdoc.createParagraph();//创建段落
xpara.setAlignment(ParagraphAlignment.CENTER);//居中
XWPFParagraph xpara1 = xdoc.createParagraph();
xpara1.setAlignment(ParagraphAlignment.RIGHT);//居右
XWPFTable xtable = xdoc.createTable(7, 4);//7行4列表格
XWPFRun run = xpara.createRun();
run.setFontSize(20);//字体大小
run