许鹏程
2023-06-09 15e225d692605505d549764e2071770e8686f8c3
src/main/java/com/product/file/util/AsposeUtil.java
@@ -33,11 +33,11 @@
           is =  AsposeUtil.class.getClassLoader().getResourceAsStream("license.xml");
            com.aspose.cells.License excel = new com.aspose.cells.License();
            excel.setLicense(is);
            is =  AsposeUtil.class.getClassLoader().getResourceAsStream("license.xml");
            com.aspose.words.License word = new com.aspose.words.License();
            word.setLicense(is);
            is =  AsposeUtil.class.getClassLoader().getResourceAsStream("license.xml");
            com.aspose.slides.License ppt = new com.aspose.slides.License();
            ppt.setLicense(is);
@@ -58,7 +58,7 @@
        return result;
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -71,8 +71,11 @@
        FileOutputStream fileOS=null;
        try {
            File file = new File(OutPutPath);
            if (!file.exists()) {
                file.mkdirs();
         if(!file.getParentFile().exists()){
            file.getParentFile().mkdirs();
         }
            if (!file.isFile()) {
            file.createNewFile();
            }
            Workbook wb = new Workbook(officePath);// 原始excel路径
            File pdfFile = new File(OutPutPath);// 输出路径
@@ -82,6 +85,7 @@
            pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
            wb.save(fileOS, pdfSaveOptions);
        } catch (Exception e) {
         e.printStackTrace();
           throw new BaseException(e);
        }finally{
         if(fileOS!=null) {
@@ -95,7 +99,7 @@
      }
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -129,7 +133,7 @@
      }
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -261,7 +265,7 @@
        }
        return OutPutPath+officeName;
    }
    public static void main(String args[]) {
       String file="E:/work/沄崃/FE6.6产品报价工具-新 - 副本.xlsx";
       AsposeUtil.OfficeToPdf(file);