用 Spire.XLS for Java工具 把Excel文件转为pdf文件


 用Spire工具 把Excel文件转为pdf文件并保存

参考Java 将Excel转为PDF    帮助文档 文档转换 Java 将 Excel 转为 PDF

1.添加jar包 或者 添加依赖

2.把C:/TEST/test.xlsx文件 转为为C:/TEST/test.pdf文件

import com.spire.xls.FileFormat;
import com.spire.xls.Workbook;

public class ExcelToPdf {

	public static void main(String[] args) {

		String newFilePath = "C:/TEST/test.xlsx";
		String newPDFPath = "C:/TEST/test.pdf";
		excelToPdf(newFilePath, newPDFPath);

	}

	public static void excelToPdf(String excelPath, String pdfPath) {

		// load excel file
		Workbook wb = new Workbook();
		wb.loadFromFile(excelPath);
		// convert excel file to pdf file
		wb.saveToFile(pdfPath, FileFormat.PDF);
	}

}

 

下载包 地址Free Spire.XLS for Java

 下载后 把Spire.Xls-FE_2.2.0.zip 解压。然后在Spire.Xls-FE_2.2.0\lib文件下找到 Spire.Xls.jar包,把Spire.Xls.jar复制到你自己的项目。就可以用了。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM