import com.aspose.cells.Workbook;
import com.aspose.cells.SaveFormat;
标签:files,file,excel,rootDir,static,File,pdf,String From: https://www.cnblogs.com/lt3232696/p/18456534
static int count = 0;
public static void main(String[] args) {
String rootDir = "F:\\333\\000";
convertAllExcelFilesToPdf(rootDir);
}
private static void convertAllExcelFilesToPdf(String rootDir) {
File directory = new File(rootDir);
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
// 递归处理子目录
convertAllExcelFilesToPdf(file.getAbsolutePath());
} else if (isExcelFile(file)) {
// 转换 Excel 文件为 PDF
convertExcelToPdf(file);
count++;
}
}
}
}
private static boolean isExcelFile(File file) {
String fileName = file.getName().toLowerCase();
return fileName.endsWith(".xls") || fileName.endsWith(".xlsx");
}