pom.xmlo依赖:

<!--POI Excel表格导出依赖-->
<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version>
</dependency><!-- 导出PDF使用 -->
<dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version>
</dependency>
<dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.4.3</version>
</dependency>

因项目原因就不展示效果图了,可自己添加静态数据查看,直接上代码,根据自己需求修改:

import com.itextpdf.text.*;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.open.capacity.common.code.C00;
import com.open.capacity.common.envm.cate.ProjDossierAuthCate;
import com.open.capacity.common.envm.status.MarkStatus;
import com.open.capacity.common.envm.status.ProjDossierAuthorityStatus;
import com.open.capacity.common.envm.status.ProjDossierStatus;
import com.open.capacity.common.envm.status.ProjStatus;
import com.open.capacity.common.exception.controller.ControllerException;
import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.common.util.SysUserUtil;
import com.open.capacity.common.web.Result;
import com.open.capacity.project.dao.*;
import com.open.capacity.project.entity.*;
import com.open.capacity.project.feign.ProjFileFeignClient;
import com.open.capacity.project.service.ProjDossierService;
import com.open.capacity.project.util.ProjDataOpLogUtil;
import com.open.capacity.project.util.ProjDataStageLogUtil;
import com.open.capacity.project.util.ZipUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.open.capacity.common.web.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;import java.io.File;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;import org.apache.commons.collections4.MapUtils;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;@Service
public class ProjDossierServiceImpl  implements ProjDossierService {/*** 导出档案明细表(pdf)** @param projDataId 项目id* @param request    request* @param response   response* @return :* @author : hjk*/@Overridepublic Result dossierInfoImportExcel(Long projDataId, HttpServletRequest request, HttpServletResponse response) {try {//其他查询逻辑//其他查询逻辑ProjDossierDTO projDossierDTO  =  projDossierDao.detail(projDataId, ProjDossierStatus.CANCEL.getCode());if ( projDossierDTO == null){projDossierDTO = projDossierDao.detailByState(projDataId, ProjDossierStatus.CANCEL.getCode());if (projDossierDTO == null){//没有数据的时候返回新对象 - add by gcj 2020-11-16projDossierDTO = new ProjDossierDTO();projDossierDTO.setProjDataId( projDataId == null ? null : projDataId.intValue() );//return Result.failedWith(id, C00.C0003.getCode(),"暂无数据");} else {projDossierDTO.setDossierName(null);projDossierDTO.setTopicCode(null);}}projDossierDTO.setArchive(false);if (projDossierDTO.getState() != null){if (projDossierDTO.getState().equals(ProjDossierStatus.YGD.getCode())){projDossierDTO.setArchive(true);}}String dossierCate = projDossierDao.getDossierCate(projDossierDTO.getDossierCate(), 43);if (StringUtils.isNotBlank(dossierCate)){projDossierDTO.setDossierCateName(dossierCate);}if (StringUtils.isBlank(projDossierDTO.getDossierName())){String projName = projDossierDao.getProjName(projDossierDTO.getProjDataId());projDossierDTO.setProjName(projName);projDossierDTO.setDossierName(projName);}//直接下载,不预览response.setHeader("Content-Disposition", "attachment; filename="+new String( ("档案卷内明细目录表" + ".pdf").getBytes(),"iso-8859-1"));//将数据以流的形式传到浏览器下载OutputStream os = response.getOutputStream();//先预先,再选择存放路径
//            response.setContentType("application/pdf");
//            response.setContentType("application/octet-stream");// 第一步,创建document对象Document document = new Document(PageSize.A4.rotate());PdfWriter.getInstance(document, os);BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);Font FontChinese12 = new Font(bfChinese, 12, Font.NORMAL);Font FontChinese12Red = new Font(bfChinese, 12, Font.NORMAL, BaseColor.RED);Font FontChinese12Blue = new Font(bfChinese, 12, Font.NORMAL, BaseColor.BLUE);Rectangle rectPageSize = new Rectangle(PageSize.A4);//第二步,打开文档document.open();//创建document对象并指定边距Document doc = new Document(rectPageSize,50,50,50,50);PdfPTable pt01 = new PdfPTable(17);PdfPCell cell01 = new PdfPCell(new Paragraph("云南锡业集团公司科技档案卷内明细目录表", FontChinese12));cell01.setColspan(17);// 设置内容水平居中显示cell01.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell01.setVerticalAlignment(Element.ALIGN_MIDDLE);pt01.addCell(cell01);document.add(pt01);PdfPTable pt02 = new PdfPTable(17);PdfPCell cell02 = new PdfPCell(new Paragraph("档案编号", FontChinese12));cell02.setColspan(2);// 设置内容水平居中显示cell02.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell02.setVerticalAlignment(Element.ALIGN_MIDDLE);pt02.addCell(cell02);document.add(pt02);if (StringUtils.isNotBlank(projDossierDTO.getDossierCode())){cell02 = new PdfPCell(new Paragraph(projDossierDTO.getDossierCode(), FontChinese12Red));} else {cell02 = new PdfPCell(new Paragraph("", FontChinese12Red));}cell02.setColspan(15);// 设置内容水平居中显示cell02.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell02.setVerticalAlignment(Element.ALIGN_MIDDLE);pt02.addCell(cell02);document.add(pt02);PdfPTable pt03 = new PdfPTable(17);PdfPCell cell03 = new PdfPCell(new Paragraph("类别及专业", FontChinese12));cell03.setColspan(2);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);if (StringUtils.isNotBlank(projDossierDTO.getDossierCateName())){cell03 = new PdfPCell(new Paragraph(projDossierDTO.getDossierCateName(), FontChinese12));} else {cell03 = new PdfPCell(new Paragraph("", FontChinese12));}cell03.setColspan(2);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);cell03 = new PdfPCell(new Paragraph("案卷名称", FontChinese12));cell03.setColspan(1);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);if (StringUtils.isNotBlank(projDossierDTO.getDossierName())){cell03 = new PdfPCell(new Paragraph(projDossierDTO.getDossierName(), FontChinese12));} else {cell03 = new PdfPCell(new Paragraph("", FontChinese12));}cell03.setColspan(6);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);cell03 = new PdfPCell(new Paragraph("工程或课题代号", FontChinese12));cell03.setColspan(3);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);if (StringUtils.isNotBlank(projDossierDTO.getTopicCode())){cell03 = new PdfPCell(new Paragraph(projDossierDTO.getTopicCode(), FontChinese12));} else {cell03 = new PdfPCell(new Paragraph("", FontChinese12));}cell03.setColspan(3);// 设置内容水平居中显示cell03.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell03.setVerticalAlignment(Element.ALIGN_MIDDLE);pt03.addCell(cell03);document.add(pt03);PdfPTable pt04 = new PdfPTable(17);PdfPCell cell04 = new PdfPCell(new Paragraph("阶段名称", FontChinese12));cell04.setColspan(2);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);if (StringUtils.isNotBlank(projDossierDTO.getStageName())){cell04 = new PdfPCell(new Paragraph(projDossierDTO.getStageName(), FontChinese12));} else {cell04 = new PdfPCell(new Paragraph("", FontChinese12));}cell04.setColspan(2);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);cell04 = new PdfPCell(new Paragraph("编制单位", FontChinese12));cell04.setColspan(1);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);if (StringUtils.isNotBlank(projDossierDTO.getCompileOrg())){cell04 = new PdfPCell(new Paragraph(projDossierDTO.getCompileOrg(), FontChinese12));} else {cell04 = new PdfPCell(new Paragraph("", FontChinese12));}cell04.setColspan(6);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);cell04 = new PdfPCell(new Paragraph("编制日期", FontChinese12));cell04.setColspan(3);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);if (StringUtils.isNotBlank(projDossierDTO.getCompileDate())){cell04 = new PdfPCell(new Paragraph(projDossierDTO.getCompileDate(), FontChinese12));} else {cell04 = new PdfPCell(new Paragraph("", FontChinese12));}cell04.setColspan(3);// 设置内容水平居中显示cell04.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell04.setVerticalAlignment(Element.ALIGN_MIDDLE);pt04.addCell(cell04);document.add(pt04);PdfPTable pt05 = new PdfPTable(17);PdfPCell cell05 = new PdfPCell(new Paragraph("序号", FontChinese12));cell05.setColspan(1);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("图(或文)号", FontChinese12));cell05.setColspan(2);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("科技材料名称", FontChinese12));cell05.setColspan(2);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("文件名称", FontChinese12));cell05.setColspan(2);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);PdfPTable pt05_1 = new PdfPTable(4);PdfPCell cell05_1 = new PdfPCell(new Paragraph("图纸", FontChinese12));cell05_1.setColspan(4);// 设置内容水平居中显示cell05_1.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_1.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_1.addCell(cell05_1);cell05_1 = new PdfPCell(new Paragraph("比例尺", FontChinese12));// 设置内容水平居中显示cell05_1.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_1.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_1.addCell(cell05_1);cell05_1 = new PdfPCell(new Paragraph("版本", FontChinese12));// 设置内容水平居中显示cell05_1.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_1.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_1.addCell(cell05_1);cell05_1 = new PdfPCell(new Paragraph("张数", FontChinese12));// 设置内容水平居中显示cell05_1.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_1.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_1.addCell(cell05_1);cell05_1 = new PdfPCell(new Paragraph("图幅", FontChinese12));// 设置内容水平居中显示cell05_1.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_1.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_1.addCell(cell05_1);//合并cell05 =new PdfPCell(pt05_1);cell05.setColspan(4);cell05.setPadding(0);pt05.addCell(cell05);document.add(pt05);PdfPTable pt05_2 = new PdfPTable(3);PdfPCell cell05_2 = new PdfPCell(new Paragraph("文字材料", FontChinese12));cell05_2.setColspan(3);// 设置内容水平居中显示cell05_2.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_2.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_2.addCell(cell05_2);cell05_2 = new PdfPCell(new Paragraph("比例尺", FontChinese12));// 设置内容水平居中显示cell05_2.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_2.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_2.addCell(cell05_2);cell05_2 = new PdfPCell(new Paragraph("版本", FontChinese12));// 设置内容水平居中显示cell05_2.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_2.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_2.addCell(cell05_2);cell05_2 = new PdfPCell(new Paragraph("张数", FontChinese12));// 设置内容水平居中显示cell05_2.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05_2.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05_2.addCell(cell05_2);//合并cell05 =new PdfPCell(pt05_2);cell05.setColspan(3);cell05.setPadding(0);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("保管期限", FontChinese12));cell05.setColspan(1);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("密级", FontChinese12));cell05.setColspan(1);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);cell05 = new PdfPCell(new Paragraph("备注", FontChinese12));cell05.setColspan(1);cell05.setRowspan(2);// 设置内容水平居中显示cell05.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell05.setVerticalAlignment(Element.ALIGN_MIDDLE);pt05.addCell(cell05);document.add(pt05);List<ProjDossierInfo> projDossierInfoList = projDossierDao.listProjDossierInfo(projDossierDTO.getProjDataId(), MarkStatus.MARK.getCode());if (!projDossierInfoList.isEmpty()){int i = 1;for (ProjDossierInfo projDossierInfo : projDossierInfoList){if (StringUtils.isBlank(projDossierInfo.getDataName())){if (StringUtils.isNotBlank(projDossierInfo.getFileUrlName())){projDossierInfo.setDataName(projDossierInfo.getFileUrlName().substring(0,projDossierInfo.getFileUrlName().lastIndexOf(".")));}}PdfPTable pt06 = new PdfPTable(17);//序号PdfPCell cell06 = new PdfPCell(new Paragraph(String.valueOf(i), FontChinese12));// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//图号if (StringUtils.isBlank(projDossierInfo.getDataCode())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getDataCode(), FontChinese12Red));}//跨列cell06.setColspan(2);// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//科技材料名称if (StringUtils.isBlank(projDossierInfo.getDataName())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getDataName(), FontChinese12Red));}//跨列cell06.setColspan(2);// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//文件名称if (StringUtils.isBlank(projDossierInfo.getFileUrlName())){cell06 = new PdfPCell(new Paragraph("", FontChinese12Blue));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getFileUrlName(), FontChinese12Blue));}//跨列cell06.setColspan(2);// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//图纸比例尺if (StringUtils.isBlank(projDossierInfo.getBlueprintScale())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getBlueprintScale(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//图纸版本if (StringUtils.isBlank(projDossierInfo.getBlueprintVersion())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getBlueprintVersion(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//图纸张数if (projDossierInfo.getBlueprintNum() == null){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getBlueprintNum().toString(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//图幅if (StringUtils.isBlank(projDossierInfo.getBlueprintSize())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getBlueprintSize(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//文件版本if (StringUtils.isBlank(projDossierInfo.getFileVersion())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getFileVersion(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//文件份数if (projDossierInfo.getFileCount() == null){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getFileCount().toString(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//文件页数if (projDossierInfo.getFilePageNum() == null){cell06 = new PdfPCell(new Paragraph("", FontChinese12Red));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getFilePageNum().toString(), FontChinese12Red));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//保管期限if (StringUtils.isBlank(projDossierInfo.getStoragePeriod())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getStoragePeriod(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//密级if (StringUtils.isBlank(projDossierInfo.getSecretsDegree())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getSecretsDegree(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);//备注if (StringUtils.isBlank(projDossierInfo.getRemarks())){cell06 = new PdfPCell(new Paragraph("", FontChinese12));} else {cell06 = new PdfPCell(new Paragraph(projDossierInfo.getRemarks(), FontChinese12));}// 设置内容水平居中显示cell06.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置垂直居中cell06.setVerticalAlignment(Element.ALIGN_MIDDLE);pt06.addCell(cell06);document.add(pt06);i++;}}document.close();os.flush();os.close();return Result.succeed(0,"导出成功");} catch (Exception e) {e.printStackTrace();}return Result.failed("导出失败");}
}

java 使用POI导出为pdf,通过浏览器直接下载相关推荐

  1. java利用poi导出excel功能-附带图片导出

    java利用poi导出excel功能-附带图片导出 写在前面 最近刚离职,闲来无事,于是把上两家公司都有碰到过的需求但都没有去研究实现:即导出带图片的excel报表.于是就折腾了一下这个功能,研究出来 ...

  2. java中poi导出Excel表格(前台流文件接收)

    java中poi导出Excel表格,前端以流的方式接收,而非直接生成文件再下载,解决多台服务器部署后,路径地址不统一导致的下载问题. 生成Excel示例图: 2.代码说明 ① 在上次的基础上增加了底部 ...

  3. Java操作poi导出Excel自定义字体颜色

    Java操作poi导出Excel自定义字体颜色 功能介绍 POI操作Excel 第一步创建一个导出的工具类 整体定义表格字体样式 自定义表格字体样式 总结 功能介绍 Apache POI 是用Java ...

  4. java用poi导出word,Java使用POI导出Word文档的操作教程,poiword

    Java使用POI导出Word文档的操作教程,poiword 一.主要pom依赖 org.apache.poi poi-ooxml 3.16 二.需要导出word模板 三.相关导出代码 package ...

  5. Java的poi导出的excel不能超过256列的解决办法

    Java的poi导出的excel不能超过256列的解决办法 背景 1.现在的情况 2.解决办法 背景 导出时如果列超过256导出就会报错,现在进行解决 1.现在的情况 excel文件名以.xls结尾 ...

  6. java程序设计实用教程高飞pdf_普通高等教育“计算机类专业”规划教材:Java程序设计实用教程习题集 pdf epub mobi txt 下载...

    普通高等教育"计算机类专业"规划教材:Java程序设计实用教程习题集 pdf epub mobi txt 下载 图书介绍 ☆☆☆☆☆ 高飞,赵小敏,陆佳炜 等 著 下载链接在页面底 ...

  7. Java使用poi导出数据到excel(包括xls和xlsx两种格式)并通过浏览器下载

    情景:将数据导出到excel是java开发常用的功能,数据量不大的时候,xls和xlsx两种格式的文件都行,但是数据量太大的时候就有区别了,xls格式的文件一个sheet页最多只能存六万多条数据,而x ...

  8. Java和poi导出excel报表

    一:poi jar下载地址:点击打开链接: 二:工程截图: 三:运行效果截图: 四:源代码: Student.java: package com.poi.bean;import java.util.D ...

  9. java使用poi导出ppt图表——环形图/空心饼图

    目录 前言 使用java poi导出图表,就是找不到环形图/空心饼图怎么做的(或者是我没找到),找到的都是饼图,柱图,线图等. 所以就简单说一下怎么导出的. 一.导入poi相关jar包 二.先创建ex ...

最新文章

  1. 【数据库】sqlite3数据库备份、导出方法汇总
  2. python数据分析设置_Python 数据分析系列之如何安装和设置 Python
  3. shell 脚本 抽取指定数量的随机学生
  4. java获取整点与凌晨的时间戳
  5. LeetCode 1474. 删除链表 M 个节点之后的 N 个节点
  6. 如何在服务器运行aspx_ASP.NET开发实战——(四)MVC是如何运行?它的生命周期是什么?...
  7. 初识EntityFramework6【转】
  8. java基础练习 2
  9. c#modbus tcp通讯助手开源_RS485和Modbus知识点汇总
  10. 理论知识内容有_育婴师培训课程包含哪些内容?
  11. Visio Professional 2016 破解教程
  12. 3分钟打动投资人:商业计划书篇
  13. Adobe Photoshop CC2018软件安装教程
  14. 怎么用html实现QQ代挂功能,如何给自己的代挂网、代刷网、底部添加腾讯云智服客服代码...
  15. python 白噪声检验-python之时间序列分析(一)
  16. Python开源指南
  17. Android 锁屏键和home键分开处理
  18. hibernate列名无效
  19. 79-Java案例:斗地主游戏
  20. 强行挂载根分区为只读,强行修复文件系统,超神的用法。

热门文章

  1. 盖茨获博士后的演讲全文
  2. 【HNOI2014】世界树
  3. jsp中去掉超链接下划线吗_网页中如何去掉超链接的下划线
  4. 高级程序员必修课--sql思维举重训练
  5. 关于fork +@(posedge xxx)触发的问题
  6. 世界上第一所区块链大学将诞生,由牛津大学研究员主导!
  7. 读《蒙台梭利敏感期早教手册》
  8. TT 的魔法猫(弗洛伊德)
  9. 奇怪了,为什么“语句未结束”
  10. JS报错:Uncaught ReferenceError: ShowDetail is not defined at HTMLAnchorElement.onclick