java利用Aspose.cells.jar将本地excel文档转化成pdf(完美破解版 无水印 无中文乱码)
下载aspose-cells-8.5.2.jar包 http://pan.baidu.com/s/1kUBzsQ7
JAVA代码
package webViewer; import java.io.*; import com.aspose.cells.*; //引入aspose-cells-8.5.2.jar包 public class Excel2Pdf { public static boolean getLicense() { boolean result = false; try { InputStream is = Test.class.getClassLoader().getResourceAsStream("xlsxlicense.xml"); // license.xml应放在..\WebRoot\WEB-INF\classes路径下 License aposeLic = new License(); aposeLic.setLicense(is); result = true; } catch (Exception e) { e.printStackTrace(); } return result; } public static void excel2pdf(String Address) { if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生 return; } try { File pdfFile = new File("C:/Program Files (x86)/Apache Software Foundation/Tomcat 7.0/webapps/generic/web/file/pdf1.pdf");// 输出路径 Workbook wb = new Workbook(Address);// 原始excel路径 FileOutputStream fileOS = new FileOutputStream(pdfFile); wb.save(fileOS, SaveFormat.PDF); fileOS.close(); } catch (Exception e) { e.printStackTrace(); } } }
调用代码
package webViewer; public class Test { public static void main(String[] args){ Excel2Pdf.excel2pdf("C:/Program Files (x86)/Apache Software Foundation/Tomcat 7.0/webapps/generic/web/file/5.xlsx"); } }
生成pdf文档
分类:
Java
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~