参考代码:
import com.spire.xls.*;
public class ExceltoPDF {
public static void main(String[] args) {
//加载一个Excel文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Sample.xlsx");
//设置转换时,工作表自适应PDF页面
workbook.getConverterSetting().setSheetFitToPage(true);
//将Excel保存为PDF
workbook.saveToFile("ToPDF.pdf",FileFormat.PDF);
}
}