|
@@ -1,43 +1,43 @@
|
|
|
-package com.flow.converter;
|
|
|
-
|
|
|
-import com.aspose.cells.License;
|
|
|
-import com.aspose.cells.PdfSaveOptions;
|
|
|
-import com.aspose.cells.Workbook;
|
|
|
-import com.flow.common.core.exception.BaseException;
|
|
|
-
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
-
|
|
|
-public class ExcelToPdfConverter implements FileConverter {
|
|
|
-
|
|
|
- /**
|
|
|
- * excel转pdf
|
|
|
- *
|
|
|
- * @param inputStream
|
|
|
- * @param outputStream
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public void convert(InputStream inputStream, OutputStream outputStream) throws Exception {
|
|
|
- this.validateLicense();
|
|
|
- Workbook wb = new Workbook(inputStream);
|
|
|
- PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
|
|
|
- pdfSaveOptions.setOnePagePerSheet(true);
|
|
|
- wb.save(outputStream, pdfSaveOptions);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证许可证,若不验证则转化出的pdf文档会有水印产生
|
|
|
- */
|
|
|
- private void validateLicense() {
|
|
|
- String licenseFilePath = "excel-license.xml";
|
|
|
- try {
|
|
|
- InputStream is = ExcelToPdfConverter.class.getClassLoader().getResourceAsStream(licenseFilePath);
|
|
|
- License license = new License();
|
|
|
- license.setLicense(is);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new BaseException("许可证验证失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+// package com.flow.converter;
|
|
|
+//
|
|
|
+// import com.aspose.cells.License;
|
|
|
+// import com.aspose.cells.PdfSaveOptions;
|
|
|
+// import com.aspose.cells.Workbook;
|
|
|
+// import com.flow.common.core.exception.BaseException;
|
|
|
+//
|
|
|
+// import java.io.InputStream;
|
|
|
+// import java.io.OutputStream;
|
|
|
+//
|
|
|
+// public class ExcelToPdfConverter implements FileConverter {
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * excel转pdf
|
|
|
+// *
|
|
|
+// * @param inputStream
|
|
|
+// * @param outputStream
|
|
|
+// * @throws Exception
|
|
|
+// */
|
|
|
+// public void convert(InputStream inputStream, OutputStream outputStream) throws Exception {
|
|
|
+// this.validateLicense();
|
|
|
+// Workbook wb = new Workbook(inputStream);
|
|
|
+// PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
|
|
|
+// pdfSaveOptions.setOnePagePerSheet(true);
|
|
|
+// wb.save(outputStream, pdfSaveOptions);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 验证许可证,若不验证则转化出的pdf文档会有水印产生
|
|
|
+// */
|
|
|
+// private void validateLicense() {
|
|
|
+// String licenseFilePath = "excel-license.xml";
|
|
|
+// try {
|
|
|
+// InputStream is = ExcelToPdfConverter.class.getClassLoader().getResourceAsStream(licenseFilePath);
|
|
|
+// License license = new License();
|
|
|
+// license.setLicense(is);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// throw new BaseException("许可证验证失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|