├── .github ├── ISSUE_TEMPLATE └── PULL_REQUEST_TEMPLATE ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── github │ └── caryyu │ └── excel2pdf │ ├── Excel.java │ ├── Excel2Pdf.java │ ├── ExcelObject.java │ ├── POIImage.java │ ├── POIUtil.java │ ├── PdfTableExcel.java │ ├── PdfTool.java │ └── Resource.java └── test ├── java └── com │ └── github │ └── caryyu │ └── excel2pdf │ └── Simple1Tests.java └── resources └── com └── github └── caryyu └── excel2pdf └── sample1 ├── case1.xls ├── case2.xls ├── case3.xls ├── case4.xls └── case5.xlsx /.github/ISSUE_TEMPLATE: -------------------------------------------------------------------------------- 1 | 提交问题之前请具体描述你的问题,为了更快对问题定位解决,请把你的 `Excel` 文件附件上传供作者调试,谢谢🙏🙏🙏! 2 | > 注意:建议删除 `Excel` 内的机密内容后再进行上传。 -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | **主要修改了哪些地方,问题类型是什么?** 2 | 3 | - [ ] 问题修复 4 | - [ ] 新功能 5 | - [ ] 代码重构 6 | - [ ] 其它问题 7 | 8 | **当前 PR 描述:** -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .git/ 3 | target/ 4 | .idea/ 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # excel2pdf 2 | An easy way to convert Excel to PDF by Java code based on Apache POI and itextpdf. 利用 JAVA 编写把 Excel 转 PDF 解决方案,依赖POI与IText库的实现。 3 | 4 | # 单文件转换 / Single files convert 5 | ``` 6 | String pathOfXls = "D:\\pdfexport\\MAD 5-3-05-Octavia NF-20131025.xls"; 7 | String pathOfPdf = "D:\\pdfexport\\MAD 5-3-05-Octavia NF-20131025.pdf"; 8 | 9 | FileInputStream fis = new FileInputStream(pathOfXls); 10 | List objects = new ArrayList(); 11 | objects.add(new ExcelObject("导航1",fis)); 12 | FileOutputStream fos = new FileOutputStream(pathOfPdf); 13 | Excel2Pdf pdf = new Excel2Pdf(objects, fos); 14 | pdf.convert(); 15 | ``` 16 | 17 | # 多文件转换 / Multiple files convert 18 | 多文件转换之后会合并至某一个 PDF 中,并且支持导航栏标题方式。 19 | ``` 20 | FileInputStream fis1 = new FileInputStream(new File("D:\\pdfexport\\MAD 5-3-05-Octavia NF-20131025.xls")); 21 | FileInputStream fis2 = new FileInputStream(new File("D:\\pdfexport\\MAD 6-1-47-Octavia NF-20131025.xls")); 22 | FileInputStream fis3 = new FileInputStream(new File("D:\\pdfexport\\MAD 038-Superb FL DS-20131025.xls")); 23 | 24 | FileOutputStream fos = new FileOutputStream(new File("D:\\test.pdf")); 25 | 26 | List objects = new ArrayList(); 27 | objects.add(new ExcelObject("1.MAD 5-3-05-Octavia NF-20131025.xls",fis1)); 28 | objects.add(new ExcelObject("2.MAD 6-1-47-Octavia NF-20131025.xls",fis2)); 29 | objects.add(new ExcelObject("3.MAD 038-Superb FL DS-20131025.xls",fis3)); 30 | 31 | Excel2Pdf pdf = new Excel2Pdf(objects , fos); 32 | pdf.convert(); 33 | ``` 34 | 35 | # 代码打包 36 | ``` 37 | package -Prelease -Dmaven.test.skip=true 38 | ``` 39 | 40 | # 贡献与建议 / Contribution 41 | 希望拿了此份代码的人改进了一些问题或提交BUG的请提交PR到这个主干上,我会做合并操作希望把这个库进行更加的完善,谢谢! 42 | All Contributions are welcomed 43 | 44 | # 后续功能计划(可能需要重构) 45 | 1、对单个 Excel 文件的 Sheet 进行 PDF 的页处理,并把 Sheet 名称当做锚; 46 | 2、支持多个 Excel 文件的 Sheet 合并,并在 PDF 页后面进行追加; 47 | 3、实现自动分辨 Excel 版式并对内容进行有效的缩放。 48 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.github.caryyu 7 | excel2pdf 8 | excel2pdf 9 | jar 10 | 1.0 11 | An easy way to convert Excel to PDF by Java code based on Apache POI and itextpdf. 12 | https://github.com/caryyu/excel2pdf 13 | 14 | 15 | 16 | The Apache Software License, Version 2.0 17 | http://www.apache.org/licenses/LICENSE-2.0.txt 18 | repo 19 | 20 | 21 | 22 | 23 | https://github.com/caryyu/excel2pdf 24 | scm:git:https://github.com/caryyu/excel2pdf.git 25 | scm:git:https://github.com/caryyu/excel2pdf.git 26 | excel2pdf-1.0 27 | 28 | 29 | 30 | 31 | caryyu 32 | 343194291@qq.com 33 | 34 | 35 | RayHu 36 | huyi0912@hotmail.com 37 | 38 | 39 | 40 | 41 | 1.6 42 | UTF-8 43 | 44 | 45 | 46 | 47 | oss 48 | https://oss.sonatype.org/content/repositories/snapshots 49 | 50 | 51 | oss 52 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 53 | 54 | 55 | 56 | 57 | 58 | junit 59 | junit 60 | 4.12 61 | 62 | 63 | commons-codec 64 | commons-codec 65 | 1.10 66 | 67 | 68 | commons-io 69 | commons-io 70 | 2.4 71 | 72 | 73 | dom4j 74 | dom4j 75 | 1.6.1 76 | 77 | 78 | org.apache.poi 79 | poi 80 | 3.9 81 | 82 | 83 | org.apache.poi 84 | poi-ooxml 85 | 3.9 86 | 87 | 88 | org.apache.poi 89 | poi-ooxml-schemas 90 | 3.9 91 | 92 | 93 | com.itextpdf 94 | itextpdf 95 | 5.5.9 96 | 97 | 98 | com.itextpdf 99 | itext-asian 100 | 5.2.0 101 | 102 | 103 | 104 | 105 | 106 | release 107 | 108 | 109 | 110 | 111 | org.apache.maven.plugins 112 | maven-source-plugin 113 | 2.1.2 114 | 115 | 116 | attach-sources 117 | 118 | jar 119 | 120 | 121 | 122 | 123 | 124 | 125 | org.apache.maven.plugins 126 | maven-javadoc-plugin 127 | 2.8.1 128 | 129 | 130 | attach-javadocs 131 | 132 | jar 133 | 134 | 135 | 136 | 137 | 138 | 139 | org.apache.maven.plugins 140 | maven-gpg-plugin 141 | 1.5 142 | 143 | 144 | sign-artifacts 145 | verify 146 | 147 | sign 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/Excel.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; 4 | import org.apache.poi.ss.usermodel.Sheet; 5 | import org.apache.poi.ss.usermodel.Workbook; 6 | import org.apache.poi.ss.usermodel.WorkbookFactory; 7 | 8 | import java.io.FileNotFoundException; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | 12 | /** 13 | * Created by cary on 6/15/17. 14 | */ 15 | public class Excel { 16 | 17 | protected Workbook wb; 18 | protected Sheet sheet; 19 | 20 | public Excel(InputStream is) { 21 | try { 22 | this.wb = WorkbookFactory.create(is); 23 | this.sheet = wb.getSheetAt(wb.getActiveSheetIndex()); 24 | } catch (FileNotFoundException e) { 25 | e.printStackTrace(); 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } catch (InvalidFormatException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | public Sheet getSheet() { 34 | return sheet; 35 | } 36 | 37 | public Workbook getWorkbook(){ 38 | return wb; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/Excel2Pdf.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import com.itextpdf.text.*; 4 | import com.itextpdf.text.pdf.*; 5 | 6 | import java.io.IOException; 7 | import java.io.OutputStream; 8 | import java.net.MalformedURLException; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by cary on 6/15/17. 14 | */ 15 | public class Excel2Pdf extends PdfTool{ 16 | protected List objects = new ArrayList(); 17 | 18 | /** 19 | *

Description: 导出单项PDF,不包含目录

20 | * @param object 21 | */ 22 | public Excel2Pdf(ExcelObject object , OutputStream os) { 23 | this.objects.add(object); 24 | this.os = os; 25 | } 26 | 27 | /** 28 | *

Description: 导出多项PDF,包含目录

29 | * @param objects 30 | */ 31 | public Excel2Pdf(List objects , OutputStream os) { 32 | this.objects = objects; 33 | this.os = os; 34 | } 35 | 36 | /** 37 | *

Description: 转换调用

38 | * @throws DocumentException 39 | * @throws MalformedURLException 40 | * @throws IOException 41 | */ 42 | public void convert() throws DocumentException, MalformedURLException, IOException { 43 | getDocument().setPageSize(PageSize.A4.rotate()); 44 | PdfWriter writer = PdfWriter.getInstance(getDocument(), os); 45 | writer.setPageEvent(new PDFPageEvent()); 46 | //Open document 47 | getDocument().open(); 48 | //Single one 49 | if(this.objects.size() <= 1){ 50 | PdfPTable table = this.toCreatePdfTable(this.objects.get(0) , getDocument() , writer); 51 | getDocument().add(table); 52 | } 53 | //Multiple ones 54 | if(this.objects.size() > 1){ 55 | toCreateContentIndexes(writer , this.getDocument() , this.objects); 56 | // 57 | for (int i = 0; i < this.objects.size(); i++) { 58 | PdfPTable table = this.toCreatePdfTable(this.objects.get(i) , getDocument() , writer); 59 | getDocument().add(table); 60 | } 61 | } 62 | // 63 | getDocument().close(); 64 | } 65 | 66 | protected PdfPTable toCreatePdfTable(ExcelObject object , Document document , PdfWriter writer) throws MalformedURLException, IOException, DocumentException{ 67 | PdfPTable table = new PdfTableExcel(object).getTable(); 68 | table.setKeepTogether(true); 69 | // table.setWidthPercentage(new float[]{100} , writer.getPageSize()); 70 | table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); 71 | return table; 72 | } 73 | 74 | /** 75 | *

Description: 内容索引创建

76 | * @throws DocumentException 77 | */ 78 | protected void toCreateContentIndexes(PdfWriter writer , Document document , List objects) throws DocumentException{ 79 | PdfPTable table = new PdfPTable(1); 80 | table.setKeepTogether(true); 81 | table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); 82 | // 83 | Font font = new Font(Resource.BASE_FONT_CHINESE , 12 , Font.NORMAL); 84 | font.setColor(new BaseColor(0,0,255)); 85 | // 86 | for (int i = 0; i < objects.size(); i++) { 87 | ExcelObject o = objects.get(i); 88 | String text = o.getAnchorName(); 89 | Anchor anchor = new Anchor(text , font); 90 | anchor.setReference("#" + o.getAnchorName()); 91 | // 92 | PdfPCell cell = new PdfPCell(anchor); 93 | cell.setBorder(0); 94 | // 95 | table.addCell(cell); 96 | } 97 | // 98 | document.add(table); 99 | } 100 | 101 | /** 102 | *

ClassName: PDFPageEvent

103 | *

Description: 事件 -> 页码控制

104 | *

Author: Cary

105 | *

Date: Oct 25, 2013

106 | */ 107 | private static class PDFPageEvent extends PdfPageEventHelper { 108 | protected PdfTemplate template; 109 | public BaseFont baseFont; 110 | 111 | @Override 112 | public void onStartPage(PdfWriter writer, Document document) { 113 | try{ 114 | this.template = writer.getDirectContent().createTemplate(100, 100); 115 | this.baseFont = new Font(Resource.BASE_FONT_CHINESE , 8, Font.NORMAL).getBaseFont(); 116 | } catch(Exception e) { 117 | throw new ExceptionConverter(e); 118 | } 119 | } 120 | 121 | @Override 122 | public void onEndPage(PdfWriter writer, Document document) { 123 | //在每页结束的时候把“第x页”信息写道模版指定位置 124 | PdfContentByte byteContent = writer.getDirectContent(); 125 | String text = "第" + writer.getPageNumber() + "页"; 126 | float textWidth = this.baseFont.getWidthPoint(text, 8); 127 | float realWidth = document.right() - textWidth; 128 | // 129 | byteContent.beginText(); 130 | byteContent.setFontAndSize(this.baseFont , 10); 131 | byteContent.setTextMatrix(realWidth , document.bottom()); 132 | byteContent.showText(text); 133 | byteContent.endText(); 134 | byteContent.addTemplate(this.template , realWidth , document.bottom()); 135 | } 136 | } 137 | } -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/ExcelObject.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import java.io.InputStream; 4 | 5 | /** 6 | * Created by cary on 6/15/17. 7 | */ 8 | public class ExcelObject { 9 | /** 10 | * 锚名称 11 | */ 12 | private String anchorName; 13 | /** 14 | * Excel Stream 15 | */ 16 | private InputStream inputStream; 17 | /** 18 | * POI Excel 19 | */ 20 | private Excel excel; 21 | 22 | public ExcelObject(InputStream inputStream){ 23 | this.inputStream = inputStream; 24 | this.excel = new Excel(this.inputStream); 25 | } 26 | 27 | public ExcelObject(String anchorName , InputStream inputStream){ 28 | this.anchorName = anchorName; 29 | this.inputStream = inputStream; 30 | this.excel = new Excel(this.inputStream); 31 | } 32 | public String getAnchorName() { 33 | return anchorName; 34 | } 35 | public void setAnchorName(String anchorName) { 36 | this.anchorName = anchorName; 37 | } 38 | public InputStream getInputStream() { 39 | return this.inputStream; 40 | } 41 | public void setInputStream(InputStream inputStream) { 42 | this.inputStream = inputStream; 43 | } 44 | Excel getExcel() { 45 | return excel; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/POIImage.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import org.apache.poi.hssf.usermodel.HSSFClientAnchor; 4 | import org.apache.poi.hssf.usermodel.HSSFPicture; 5 | import org.apache.poi.hssf.usermodel.HSSFShape; 6 | import org.apache.poi.hssf.usermodel.HSSFSheet; 7 | import org.apache.poi.ss.usermodel.Cell; 8 | import org.apache.poi.ss.usermodel.ClientAnchor; 9 | import org.apache.poi.ss.usermodel.PictureData; 10 | import org.apache.poi.ss.usermodel.Sheet; 11 | 12 | import java.awt.Dimension; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by cary on 6/15/17. 17 | */ 18 | public class POIImage { 19 | protected Dimension dimension; 20 | protected byte[] bytes; 21 | protected ClientAnchor anchor; 22 | 23 | public POIImage getCellImage(Cell cell) { 24 | Sheet sheet = cell.getSheet(); 25 | if (sheet instanceof HSSFSheet) { 26 | HSSFSheet hssfSheet = (HSSFSheet) sheet; 27 | if (hssfSheet.getDrawingPatriarch() != null) { 28 | List shapes = hssfSheet.getDrawingPatriarch().getChildren(); 29 | for (HSSFShape shape : shapes) { 30 | HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor(); 31 | if (shape instanceof HSSFPicture) { 32 | HSSFPicture pic = (HSSFPicture) shape; 33 | PictureData data = pic.getPictureData(); 34 | String extension = data.suggestFileExtension(); 35 | int row1 = anchor.getRow1(); 36 | int row2 = anchor.getRow2(); 37 | int col1 = anchor.getCol1(); 38 | int col2 = anchor.getCol2(); 39 | if (row1 == cell.getRowIndex() && col1 == cell.getColumnIndex()) { 40 | dimension = pic.getImageDimension(); 41 | this.anchor = anchor; 42 | this.bytes = data.getData(); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | return this; 49 | } 50 | 51 | public Dimension getDimension() { 52 | return dimension; 53 | } 54 | 55 | public void setDimension(Dimension dimension) { 56 | this.dimension = dimension; 57 | } 58 | 59 | public byte[] getBytes() { 60 | return bytes; 61 | } 62 | 63 | public void setBytes(byte[] bytes) { 64 | this.bytes = bytes; 65 | } 66 | 67 | public ClientAnchor getAnchor() { 68 | return anchor; 69 | } 70 | 71 | public void setAnchor(ClientAnchor anchor) { 72 | this.anchor = anchor; 73 | } 74 | } -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/POIUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import com.itextpdf.text.FontFactory; 4 | import com.itextpdf.text.pdf.BaseFont; 5 | import org.apache.poi.hssf.usermodel.HSSFFont; 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.hssf.util.HSSFColor; 8 | import org.apache.poi.ss.usermodel.Workbook; 9 | import org.apache.poi.xssf.usermodel.XSSFColor; 10 | import org.apache.poi.ss.usermodel.Color; 11 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; 12 | 13 | import javax.imageio.ImageIO; 14 | import java.awt.*; 15 | import java.awt.geom.AffineTransform; 16 | import java.awt.image.BufferedImage; 17 | import java.awt.image.ColorModel; 18 | import java.awt.image.WritableRaster; 19 | import java.io.ByteArrayInputStream; 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.IOException; 22 | 23 | /** 24 | * 工具类 25 | */ 26 | public class POIUtil { 27 | /** 28 | * 获取单元格颜色 29 | * 30 | * @param color 单元格颜色 31 | * @return RGB 三通道颜色, 默认: 黑色 32 | */ 33 | public static int getRGB(Color color) { 34 | int result = 0x00FFFFFF; 35 | 36 | int red = 0; 37 | int green = 0; 38 | int blue = 0; 39 | 40 | if (color instanceof HSSFColor) { 41 | HSSFColor hssfColor = (HSSFColor) color; 42 | short[] rgb = hssfColor.getTriplet(); 43 | red = rgb[0]; 44 | green = rgb[1]; 45 | blue = rgb[2]; 46 | } 47 | 48 | if (color instanceof XSSFColor) { 49 | XSSFColor xssfColor = (XSSFColor) color; 50 | byte[] rgb = xssfColor.getRgb(); 51 | if (rgb != null) { 52 | red = (rgb[0] < 0) ? (rgb[0] + 256) : rgb[0]; 53 | green = (rgb[1] < 0) ? (rgb[1] + 256) : rgb[1]; 54 | blue = (rgb[2] < 0) ? (rgb[2] + 256) : rgb[2]; 55 | } 56 | } 57 | 58 | if (red != 0 || green != 0 || blue != 0) { 59 | result = new java.awt.Color(red, green, blue).getRGB(); 60 | } 61 | 62 | return result; 63 | } 64 | 65 | /** 66 | * 获取边框的颜色 67 | * 68 | * @param wb 文档对象 69 | * @param index 颜色版索引 70 | * @return RGB 三通道颜色 71 | */ 72 | public static int getBorderRBG(Workbook wb, short index) { 73 | int result = 0; 74 | 75 | if (wb instanceof HSSFWorkbook) { 76 | HSSFWorkbook hwb = (HSSFWorkbook) wb; 77 | HSSFColor color = hwb.getCustomPalette().getColor(index); 78 | if (color != null) { 79 | result = getRGB(color); 80 | } 81 | } 82 | 83 | if (wb instanceof XSSFWorkbook) { 84 | XSSFColor color = new XSSFColor(); 85 | color.setIndexed(index); 86 | result = getRGB(color); 87 | } 88 | 89 | return result; 90 | } 91 | 92 | public static com.itextpdf.text.Font toItextFont(org.apache.poi.ss.usermodel.Font font) { 93 | com.itextpdf.text.Font iTextFont = FontFactory.getFont(font.getFontName(), 94 | BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 95 | font.getFontHeightInPoints()); 96 | return iTextFont; 97 | } 98 | 99 | @SuppressWarnings("finally") 100 | public static byte[] scale(byte[] bytes, double width, double height) { 101 | BufferedImage bufferedImage = null; 102 | BufferedImage bufTarget = null; 103 | try { 104 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 105 | bufferedImage = ImageIO.read(bais); 106 | double sx = width / bufferedImage.getWidth(); 107 | double sy = height / bufferedImage.getHeight(); 108 | int type = bufferedImage.getType(); 109 | if (type == BufferedImage.TYPE_CUSTOM) { 110 | ColorModel cm = bufferedImage.getColorModel(); 111 | WritableRaster raster = cm.createCompatibleWritableRaster((int) width, (int) height); 112 | boolean alphaPremultiplied = cm.isAlphaPremultiplied(); 113 | bufTarget = new BufferedImage(cm, raster, alphaPremultiplied, null); 114 | } else { 115 | bufTarget = new BufferedImage((int) width, (int) height, type); 116 | } 117 | 118 | Graphics2D g = bufTarget.createGraphics(); 119 | g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); 120 | g.drawRenderedImage(bufferedImage, AffineTransform.getScaleInstance(sx, sy)); 121 | g.dispose(); 122 | 123 | if (bufTarget != null) { 124 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 125 | ImageIO.write(bufTarget, "png", baos); 126 | byte[] result = baos.toByteArray(); 127 | return result; 128 | } 129 | } catch (IOException e) { 130 | e.printStackTrace(); 131 | } 132 | return null; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/PdfTableExcel.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import com.itextpdf.text.*; 4 | import com.itextpdf.text.Font; 5 | import com.itextpdf.text.pdf.PdfPCell; 6 | import com.itextpdf.text.pdf.PdfPTable; 7 | import org.apache.poi.hssf.usermodel.HSSFCellStyle; 8 | import org.apache.poi.hssf.util.HSSFColor; 9 | import org.apache.poi.ss.format.CellNumberFormatter; 10 | import org.apache.poi.ss.usermodel.*; 11 | import org.apache.poi.ss.util.CellRangeAddress; 12 | 13 | import java.io.IOException; 14 | import java.net.MalformedURLException; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by cary on 6/15/17. 20 | */ 21 | public class PdfTableExcel { 22 | protected ExcelObject excelObject; 23 | protected Excel excel; 24 | protected boolean setting = false; 25 | 26 | /** 27 | *

Description: Constructor

28 | * @param excelObject 29 | */ 30 | public PdfTableExcel(ExcelObject excelObject){ 31 | this.excelObject = excelObject; 32 | this.excel = excelObject.getExcel(); 33 | } 34 | 35 | /** 36 | *

Description: 获取转换过的Excel内容Table

37 | * @return PdfPTable 38 | * @throws BadElementException 39 | * @throws MalformedURLException 40 | * @throws IOException 41 | */ 42 | public PdfPTable getTable() throws BadElementException, MalformedURLException, IOException { 43 | Sheet sheet = this.excel.getSheet(); 44 | return toParseContent(sheet); 45 | } 46 | 47 | // private PdfPCell createPdfPCell(int colIndex, int rowIndex, Cell cell) { 48 | // 49 | // } 50 | 51 | protected PdfPTable toParseContent(Sheet sheet) throws BadElementException, MalformedURLException, IOException{ 52 | int rows = sheet.getPhysicalNumberOfRows(); 53 | 54 | List cells = new ArrayList(); 55 | float[] widths = null; 56 | float mw = 0; 57 | for (int i = 0; i < rows; i++) { 58 | Row row = sheet.getRow(i); 59 | int columns = row.getLastCellNum(); 60 | 61 | float[] cws = new float[columns]; 62 | for (int j = 0; j < columns; j++) { 63 | Cell cell = row.getCell(j); 64 | if (cell == null) cell = row.createCell(j); 65 | 66 | float cw = getPOIColumnWidth(cell); 67 | cws[cell.getColumnIndex()] = cw; 68 | 69 | // if(isUsed(cell.getColumnIndex(), row.getRowNum())){ 70 | // continue; 71 | // } 72 | 73 | cell.setCellType(Cell.CELL_TYPE_STRING); 74 | CellRangeAddress range = getColspanRowspanByExcel(row.getRowNum(), cell.getColumnIndex()); 75 | 76 | int rowspan = 1; 77 | int colspan = 1; 78 | if (range != null) { 79 | rowspan = range.getLastRow() - range.getFirstRow() + 1; 80 | colspan = range.getLastColumn() - range.getFirstColumn() + 1; 81 | } 82 | 83 | PdfPCell pdfpCell = new PdfPCell(); 84 | pdfpCell.setBackgroundColor(new BaseColor(POIUtil.getRGB( 85 | cell.getCellStyle().getFillForegroundColorColor()))); 86 | pdfpCell.setColspan(colspan); 87 | pdfpCell.setRowspan(rowspan); 88 | pdfpCell.setVerticalAlignment(getVAlignByExcel(cell.getCellStyle().getVerticalAlignment())); 89 | pdfpCell.setHorizontalAlignment(getHAlignByExcel(cell.getCellStyle().getAlignment())); 90 | pdfpCell.setPhrase(getPhrase(cell)); 91 | 92 | if (sheet.getDefaultRowHeightInPoints() != row.getHeightInPoints()) { 93 | pdfpCell.setFixedHeight(this.getPixelHeight(row.getHeightInPoints())); 94 | } 95 | 96 | addBorderByExcel(pdfpCell, cell.getCellStyle()); 97 | addImageByPOICell(pdfpCell , cell , cw); 98 | 99 | cells.add(pdfpCell); 100 | j += colspan - 1; 101 | } 102 | 103 | float rw = 0; 104 | for (int j = 0; j < cws.length; j++) { 105 | rw += cws[j]; 106 | } 107 | if (rw > mw || mw == 0) { 108 | widths = cws; 109 | mw = rw; 110 | } 111 | } 112 | 113 | PdfPTable table = new PdfPTable(widths); 114 | table.setWidthPercentage(100); 115 | // table.setLockedWidth(true); 116 | for (PdfPCell pdfpCell : cells) { 117 | table.addCell(pdfpCell); 118 | } 119 | return table; 120 | } 121 | 122 | protected Phrase getPhrase(Cell cell) { 123 | if(this.setting || this.excelObject.getAnchorName() == null){ 124 | return new Phrase(cell.getStringCellValue(), getFontByExcel(cell.getCellStyle())); 125 | } 126 | Anchor anchor = new Anchor(cell.getStringCellValue() , getFontByExcel(cell.getCellStyle())); 127 | anchor.setName(this.excelObject.getAnchorName()); 128 | this.setting = true; 129 | return anchor; 130 | } 131 | 132 | protected void addImageByPOICell(PdfPCell pdfpCell , Cell cell , float cellWidth) throws BadElementException, MalformedURLException, IOException{ 133 | POIImage poiImage = new POIImage().getCellImage(cell); 134 | byte[] bytes = poiImage.getBytes(); 135 | if(bytes != null){ 136 | // double cw = cellWidth; 137 | // double ch = pdfpCell.getFixedHeight(); 138 | // 139 | // double iw = poiImage.getDimension().getWidth(); 140 | // double ih = poiImage.getDimension().getHeight(); 141 | // 142 | // double scale = cw / ch; 143 | // 144 | // double nw = iw * scale; 145 | // double nh = ih - (iw - nw); 146 | // 147 | // POIUtil.scale(bytes , nw , nh); 148 | pdfpCell.setVerticalAlignment(Element.ALIGN_MIDDLE); 149 | pdfpCell.setHorizontalAlignment(Element.ALIGN_CENTER); 150 | Image image = Image.getInstance(bytes); 151 | pdfpCell.setImage(image); 152 | } 153 | } 154 | 155 | protected float getPixelHeight(float poiHeight){ 156 | float pixel = poiHeight / 28.6f * 26f; 157 | return pixel; 158 | } 159 | 160 | /** 161 | *

Description: 此处获取Excel的列宽像素(无法精确实现,期待有能力的朋友进行改善此处)

162 | * @param cell 163 | * @return 像素宽 164 | */ 165 | protected int getPOIColumnWidth(Cell cell) { 166 | int poiCWidth = excel.getSheet().getColumnWidth(cell.getColumnIndex()); 167 | int colWidthpoi = poiCWidth; 168 | int widthPixel = 0; 169 | if (colWidthpoi >= 416) { 170 | widthPixel = (int) (((colWidthpoi - 416.0) / 256.0) * 8.0 + 13.0 + 0.5); 171 | } else { 172 | widthPixel = (int) (colWidthpoi / 416.0 * 13.0 + 0.5); 173 | } 174 | return widthPixel; 175 | } 176 | 177 | protected CellRangeAddress getColspanRowspanByExcel(int rowIndex, int colIndex) { 178 | CellRangeAddress result = null; 179 | Sheet sheet = excel.getSheet(); 180 | int num = sheet.getNumMergedRegions(); 181 | for (int i = 0; i < num; i++) { 182 | CellRangeAddress range = sheet.getMergedRegion(i); 183 | if (range.getFirstColumn() == colIndex && range.getFirstRow() == rowIndex) { 184 | result = range; 185 | } 186 | } 187 | return result; 188 | } 189 | 190 | protected boolean isUsed(int colIndex , int rowIndex){ 191 | boolean result = false; 192 | Sheet sheet = excel.getSheet(); 193 | int num = sheet.getNumMergedRegions(); 194 | for (int i = 0; i < num; i++) { 195 | CellRangeAddress range = sheet.getMergedRegion(i); 196 | int firstRow = range.getFirstRow(); 197 | int lastRow = range.getLastRow(); 198 | int firstColumn = range.getFirstColumn(); 199 | int lastColumn = range.getLastColumn(); 200 | if (firstRow < rowIndex && lastRow >= rowIndex) { 201 | if(firstColumn <= colIndex && lastColumn >= colIndex){ 202 | result = true; 203 | } 204 | } 205 | } 206 | return result; 207 | } 208 | 209 | protected Font getFontByExcel(CellStyle style) { 210 | Font result = new Font(Resource.BASE_FONT_CHINESE , 8 , Font.NORMAL); 211 | Workbook wb = excel.getWorkbook(); 212 | 213 | short index = style.getFontIndex(); 214 | org.apache.poi.ss.usermodel.Font font = wb.getFontAt(index); 215 | 216 | if(font.getBoldweight() == org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD){ 217 | result.setStyle(Font.BOLD); 218 | } 219 | 220 | HSSFColor color = HSSFColor.getIndexHash().get(font.getColor()); 221 | 222 | if(color != null){ 223 | int rbg = POIUtil.getRGB(color); 224 | result.setColor(new BaseColor(rbg)); 225 | } 226 | 227 | FontUnderline underline = FontUnderline.valueOf(font.getUnderline()); 228 | if(underline == FontUnderline.SINGLE){ 229 | String ulString = Font.FontStyle.UNDERLINE.getValue(); 230 | result.setStyle(ulString); 231 | } 232 | return result; 233 | } 234 | 235 | protected void addBorderByExcel(PdfPCell cell , CellStyle style) { 236 | Workbook wb = excel.getWorkbook(); 237 | cell.setBorderColorLeft(new BaseColor(POIUtil.getBorderRBG(wb,style.getLeftBorderColor()))); 238 | cell.setBorderColorRight(new BaseColor(POIUtil.getBorderRBG(wb,style.getRightBorderColor()))); 239 | cell.setBorderColorTop(new BaseColor(POIUtil.getBorderRBG(wb,style.getTopBorderColor()))); 240 | cell.setBorderColorBottom(new BaseColor(POIUtil.getBorderRBG(wb,style.getBottomBorderColor()))); 241 | } 242 | 243 | protected int getVAlignByExcel(short align) { 244 | int result = 0; 245 | if (align == CellStyle.VERTICAL_BOTTOM) { 246 | result = Element.ALIGN_BOTTOM; 247 | } 248 | if (align == CellStyle.VERTICAL_CENTER) { 249 | result = Element.ALIGN_MIDDLE; 250 | } 251 | if (align == CellStyle.VERTICAL_JUSTIFY) { 252 | result = Element.ALIGN_JUSTIFIED; 253 | } 254 | if (align == CellStyle.VERTICAL_TOP) { 255 | result = Element.ALIGN_TOP; 256 | } 257 | return result; 258 | } 259 | 260 | protected int getHAlignByExcel(short align) { 261 | int result = 0; 262 | if (align == CellStyle.ALIGN_LEFT) { 263 | result = Element.ALIGN_LEFT; 264 | } 265 | if (align == CellStyle.ALIGN_RIGHT) { 266 | result = Element.ALIGN_RIGHT; 267 | } 268 | if (align == CellStyle.ALIGN_JUSTIFY) { 269 | result = Element.ALIGN_JUSTIFIED; 270 | } 271 | if (align == CellStyle.ALIGN_CENTER) { 272 | result = Element.ALIGN_CENTER; 273 | } 274 | return result; 275 | } 276 | } -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/PdfTool.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import com.itextpdf.text.Document; 4 | 5 | import java.io.OutputStream; 6 | 7 | /** 8 | * Created by cary on 6/15/17. 9 | */ 10 | public class PdfTool { 11 | // 12 | protected Document document; 13 | // 14 | protected OutputStream os; 15 | 16 | public Document getDocument() { 17 | if (document == null) { 18 | document = new Document(); 19 | } 20 | return document; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/github/caryyu/excel2pdf/Resource.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import org.apache.poi.hssf.usermodel.*; 4 | 5 | import com.itextpdf.text.*; 6 | import com.itextpdf.text.pdf.BaseFont; 7 | 8 | /** 9 | * Created by cary on 6/15/17. 10 | */ 11 | public class Resource { 12 | /** 13 | * 中文字体支持 14 | */ 15 | protected static BaseFont BASE_FONT_CHINESE; 16 | static { 17 | try { 18 | BASE_FONT_CHINESE = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); 19 | // 搜尋系統,載入系統內的字型(慢) 20 | FontFactory.registerDirectories(); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | /** 27 | * 將 POI Font 轉換到 iText Font 28 | * @param font 29 | * @return 30 | */ 31 | public static com.itextpdf.text.Font getFont(HSSFFont font) { 32 | try { 33 | com.itextpdf.text.Font iTextFont = FontFactory.getFont(font.getFontName(), 34 | BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 35 | font.getFontHeightInPoints()); 36 | return iTextFont; 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | return null; 41 | } 42 | } -------------------------------------------------------------------------------- /src/test/java/com/github/caryyu/excel2pdf/Simple1Tests.java: -------------------------------------------------------------------------------- 1 | package com.github.caryyu.excel2pdf; 2 | 3 | import com.itextpdf.text.DocumentException; 4 | import org.junit.Test; 5 | 6 | import java.io.*; 7 | import java.util.Arrays; 8 | 9 | public class Simple1Tests { 10 | @Test 11 | public void testCase1OfSingle() throws IOException, DocumentException { 12 | String fileIn = "sample1/case1.xls"; 13 | 14 | InputStream in = this.getClass().getResourceAsStream(fileIn); 15 | Excel2Pdf excel2Pdf = new Excel2Pdf(Arrays.asList( 16 | new ExcelObject(in) 17 | ), new FileOutputStream(fileOut(fileIn))); 18 | excel2Pdf.convert(); 19 | } 20 | 21 | @Test 22 | public void testCase5() throws IOException, DocumentException { 23 | String fileIn = "sample1/case5.xlsx"; 24 | 25 | InputStream in = this.getClass().getResourceAsStream(fileIn); 26 | Excel2Pdf excel2Pdf = new Excel2Pdf(Arrays.asList( 27 | new ExcelObject(in) 28 | ), new FileOutputStream(fileOut(fileIn))); 29 | excel2Pdf.convert(); 30 | } 31 | 32 | private File fileOut(String fileIn) { 33 | String uri = this.getClass().getResource(fileIn).getPath(); 34 | String fileOut = uri.replaceAll(".xls$|.xlsx$",".pdf"); 35 | File file = new File(fileOut); 36 | return file; 37 | } 38 | } -------------------------------------------------------------------------------- /src/test/resources/com/github/caryyu/excel2pdf/sample1/case1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caryyu/excel2pdf/84040623dee893ea48e943c1de1004595e2f47fd/src/test/resources/com/github/caryyu/excel2pdf/sample1/case1.xls -------------------------------------------------------------------------------- /src/test/resources/com/github/caryyu/excel2pdf/sample1/case2.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caryyu/excel2pdf/84040623dee893ea48e943c1de1004595e2f47fd/src/test/resources/com/github/caryyu/excel2pdf/sample1/case2.xls -------------------------------------------------------------------------------- /src/test/resources/com/github/caryyu/excel2pdf/sample1/case3.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caryyu/excel2pdf/84040623dee893ea48e943c1de1004595e2f47fd/src/test/resources/com/github/caryyu/excel2pdf/sample1/case3.xls -------------------------------------------------------------------------------- /src/test/resources/com/github/caryyu/excel2pdf/sample1/case4.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caryyu/excel2pdf/84040623dee893ea48e943c1de1004595e2f47fd/src/test/resources/com/github/caryyu/excel2pdf/sample1/case4.xls -------------------------------------------------------------------------------- /src/test/resources/com/github/caryyu/excel2pdf/sample1/case5.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caryyu/excel2pdf/84040623dee893ea48e943c1de1004595e2f47fd/src/test/resources/com/github/caryyu/excel2pdf/sample1/case5.xlsx --------------------------------------------------------------------------------