| | |
| | | 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); |
| | |
| | | return result; |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | 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);// 输出路径 |
| | |
| | | pdfSaveOptions.setAllColumnsInOnePagePerSheet(true); |
| | | wb.save(fileOS, pdfSaveOptions); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new BaseException(e); |
| | | }finally{ |
| | | if(fileOS!=null) { |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | } |
| | | return OutPutPath+officeName; |
| | | } |
| | | |
| | | |
| | | public static void main(String args[]) { |
| | | String file="E:/work/沄崃/FE6.6产品报价工具-新 - 副本.xlsx"; |
| | | AsposeUtil.OfficeToPdf(file); |