依赖:
<dependency>
<groupId>com.spire</groupId>
<artifactId>xls</artifactId>
<version>5.1.0</version>
</dependency>
由于阿里仓库无法下载,需要手动导入本地仓库
mvn install:install-file -DgroupId=com.spire -DartifactId=xls -Dversion=5.1.0 -Dpackaging=jar -Dfile=C:\Users\1\Downloads\Spire.Xls-FE_5.1.0\lib\Spire.Xls.jar
使用:
String df = format.format(date);
String fileUrl = path+"/file/税单"+df+".xls";
FileOutputStream stream =new FileOutputStream(fileUrl);
wb.write(stream);
//out.close();
com.spire.xls.Workbook workbook = new com.spire.xls.Workbook();
workbook.loadFromFile(fileUrl);
String imgName=path+"/file/png/税单"+df+".png";
Worksheet sheets = workbook.getWorksheets().get(0);
sheets.saveToImage(imgName);