From 4e9dcafac8479bf89d9173fd82a6e0c70d083e32 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 20 五月 2024 09:11:20 +0800
Subject: [PATCH] git ch
---
server/company/pom.xml | 1
server/service/pom.xml | 8 ++++
server/platform/pom.xml | 1
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java | 102 +++++++++++++++++++++++++-------------------------
server/shop/pom.xml | 1
server/service/src/lib/jacob.jar | 0
6 files changed, 62 insertions(+), 51 deletions(-)
diff --git a/server/company/pom.xml b/server/company/pom.xml
index 1a3f071..cc80143 100644
--- a/server/company/pom.xml
+++ b/server/company/pom.xml
@@ -41,6 +41,7 @@
<fork>true</fork>
<mainClass>com.doumee.CompanyApplication</mainClass>
<layout>ZIP</layout>
+ <includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>
diff --git a/server/platform/pom.xml b/server/platform/pom.xml
index c7faa79..fc02c10 100644
--- a/server/platform/pom.xml
+++ b/server/platform/pom.xml
@@ -36,6 +36,7 @@
<fork>true</fork>
<mainClass>com.doumee.PlatformApplication</mainClass>
<layout>ZIP</layout>
+ <includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>
diff --git a/server/service/pom.xml b/server/service/pom.xml
index 57b1ea7..36a23de 100644
--- a/server/service/pom.xml
+++ b/server/service/pom.xml
@@ -23,6 +23,14 @@
</dependency>
<!--jacob渚濊禆-->
+ <dependency>
+ <groupId>com.jacob</groupId>
+ <artifactId>jacob</artifactId>
+ <version>1.19</version>
+ <scope>system</scope>
+ <!--鏈湴鐨刯acob.jar鐨勮矾寰�-->
+ <systemPath>${project.basedir}/src/lib/jacob.jar</systemPath>
+ </dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
diff --git a/server/service/src/lib/jacob.jar b/server/service/src/lib/jacob.jar
new file mode 100644
index 0000000..35ce4fa
--- /dev/null
+++ b/server/service/src/lib/jacob.jar
Binary files differ
diff --git a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java
index 91a60aa..b865a52 100644
--- a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java
+++ b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelToPdfToolNew.java
@@ -8,43 +8,43 @@
public class ExcelToPdfToolNew {
- /**
- * 浣跨敤jacob瀹炵幇excel杞琍DF
- *
- */
+ /**
+ * 浣跨敤jacob瀹炵幇excel杞琍DF
+ *
+ */
public static void excelToPdf(String inputFilePath, String outputFilePath) {
- ActiveXComponent ax = null;
- Dispatch excel = null;
- try {
- ComThread.InitSTA();
- ax = new ActiveXComponent("Excel.Application");
- ax.setProperty("Visible", new Variant(false));
- // 绂佺敤瀹�
- ax.setProperty("AutomationSecurity", new Variant(3));
- Dispatch excels = ax.getProperty("Workbooks").toDispatch();
- Object[] obj = {
- inputFilePath,
- new Variant(false),
- new Variant(false)
- };
- excel = Dispatch.invoke(excels, "Open", Dispatch.Method, obj, new int[9]).toDispatch();
- Dispatch currentSheet = Dispatch.get(excel,
- "ActiveSheet").toDispatch();
- // 鑾峰彇椤甸潰璁剧疆
- Dispatch pageSetup = Dispatch.get(currentSheet, "PageSetup") .toDispatch();
- Dispatch.put(pageSetup, "Orientation", new Variant(2));
- Dispatch.put(pageSetup, "FitToPagesTall", new Variant(false));
- Dispatch.put(pageSetup, "FitToPagesWide", new Variant(false));
- // 鑾峰彇椤甸潰璁剧疆
+ ActiveXComponent ax = null;
+ Dispatch excel = null;
+ try {
+ ComThread.InitSTA();
+ ax = new ActiveXComponent("Excel.Application");
+ ax.setProperty("Visible", new Variant(false));
+ // 绂佺敤瀹�
+ ax.setProperty("AutomationSecurity", new Variant(3));
+ Dispatch excels = ax.getProperty("Workbooks").toDispatch();
+ Object[] obj = {
+ inputFilePath,
+ new Variant(false),
+ new Variant(false)
+ };
+ excel = Dispatch.invoke(excels, "Open", Dispatch.Method, obj, new int[9]).toDispatch();
+ Dispatch currentSheet = Dispatch.get(excel,
+ "ActiveSheet").toDispatch();
+ // 鑾峰彇椤甸潰璁剧疆
+ Dispatch pageSetup = Dispatch.get(currentSheet, "PageSetup") .toDispatch();
+ Dispatch.put(pageSetup, "Orientation", new Variant(2));
+ Dispatch.put(pageSetup, "FitToPagesTall", new Variant(0));
+ Dispatch.put(pageSetup, "FitToPagesWide", new Variant(1));
+ // 鑾峰彇椤甸潰璁剧疆
// Dispatch.put(pageSetup, "PaperSize", pageSize);
- // 鍐呭缂╂斁
+ // 鍐呭缂╂斁
// Dispatch.put(pageSetup, "Zoom", new Variant(false));
- // Dispatch Application = Dispatch.get(currentSheet, "Application") .toDispatch();
+ // Dispatch Application = Dispatch.get(currentSheet, "Application") .toDispatch();
// Dispatch.put(pageSetup, "PaperSize", pageSize);
// Dispatch.put(Application, "ActivePrinter", "Microsoft Print to PDF");
- // 鍐呭缂╂斁
+ // 鍐呭缂╂斁
// Dispatch.put(pageSetup, "Orientation", new Variant(2));
// Dispatch.put(pageSetup, "Zoom", new Variant(false));
// Dispatch.put(pageSetup, "FitToPagesWide", new Variant(1));
@@ -52,29 +52,29 @@
// Dispatch.put(pageSetup, "PaperSize", new Variant(8)); // A3鏄�8锛孉4鏄�9锛孉5鏄�11绛夌瓑
- // 杞崲鏍煎紡
- Object[] obj2 = {
- // PDF鏍煎紡绛変簬0
- new Variant(0),
- outputFilePath,
- // 0=鏍囧噯锛堢敓鎴愮殑PDF鍥剧墖涓嶄細妯$硦锛夛紝1=鏈�灏忕殑鏂囦欢
- new Variant(0)
- };
- Dispatch.invoke(excel, "ExportAsFixedFormat", Dispatch.Method, obj2, new int[1]);
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- } finally {
- if (excel != null) {
- Dispatch.call(excel, "Close", new Variant(false));
- }
- if (ax != null) {
- ax.invoke("Quit", new Variant[]{});
- ax = null;
- }
- ComThread.Release();
+ // 杞崲鏍煎紡
+ Object[] obj2 = {
+ // PDF鏍煎紡绛変簬0
+ new Variant(0),
+ outputFilePath,
+ // 0=鏍囧噯锛堢敓鎴愮殑PDF鍥剧墖涓嶄細妯$硦锛夛紝1=鏈�灏忕殑鏂囦欢
+ new Variant(0)
+ };
+ Dispatch.invoke(excel, "ExportAsFixedFormat", Dispatch.Method, obj2, new int[1]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ } finally {
+ if (excel != null) {
+ Dispatch.call(excel, "Close", new Variant(false));
}
+ if (ax != null) {
+ ax.invoke("Quit", new Variant[]{});
+ ax = null;
+ }
+ ComThread.Release();
}
+ }
public static void main(String[] args) {
String inputExcelPath = "D:\\4.xlsx";
diff --git a/server/shop/pom.xml b/server/shop/pom.xml
index ed19a83..5e2f480 100644
--- a/server/shop/pom.xml
+++ b/server/shop/pom.xml
@@ -38,6 +38,7 @@
<fork>true</fork>
<mainClass>com.doumee.ShopApplication</mainClass>
<layout>ZIP</layout>
+ <includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>
--
Gitblit v1.9.3