用 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