1、jar包
<dependency>
<groupId>com.aspose.cells</groupId>
<artifactId>aspose-cells</artifactId>
<version>8.5.2</version>
</dependency>
2、在根目录放:license.xml
具体资源请下载:
https://download.csdn.net/download/gzc_870301/12403483
/**
*@description excel转pdf 解决折叠问题(列太多)
* @author gezc30201
* @date 2020/5/9
*/
@Slf4j
public class ExcelToPdfUtil {
/**
*@description 获取license 去除水印
* @return
* @author gezc30201
* @date 2020/5/9
*/
public static boolean getLicense() {
boolean result = false;
try {
InputStream is = ExcelToPdfUtil.class.getClassLoader().getResourceAsStream("\\license.xml");
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
*@description excel 转为pdf 输出。
* @param sourceFilePath excel文件
* @param desFilePathd pad 输出文件目录
* @return void
* @author gezc30201
* @date 2020/5/9
*/
public static void excel2pdf(String sourceFilePath, String desFilePathd ){
if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
return;
}
try {
Workbook wb = n