|
|
@ -3,7 +3,6 @@ package com.yxt.common.base.utils; |
|
|
|
import com.jacob.activeX.ActiveXComponent; |
|
|
|
import com.jacob.com.ComThread; |
|
|
|
import com.jacob.com.Dispatch; |
|
|
|
import com.jacob.com.Variant; |
|
|
|
import freemarker.template.Configuration; |
|
|
|
import freemarker.template.Template; |
|
|
|
import freemarker.template.Version; |
|
|
@ -91,6 +90,7 @@ public class WordUtils { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
Dispatch document = null; |
|
|
|
try { |
|
|
|
ComThread.InitSTA(); |
|
|
|
// 打开word
|
|
|
|
app = new ActiveXComponent("Word.Application"); |
|
|
|
// 获得word中所有打开的文档
|
|
|
@ -116,13 +116,14 @@ public class WordUtils { |
|
|
|
// 关闭文档
|
|
|
|
Dispatch.call(document, "Close", false); |
|
|
|
// 关闭office
|
|
|
|
// app.invoke("Quit", 0);
|
|
|
|
app.invoke("Quit", 0); |
|
|
|
System.out.println("关闭文档"); |
|
|
|
if (app != null) |
|
|
|
app.invoke("Quit", new Variant[]{}); |
|
|
|
// if (app != null)
|
|
|
|
// app.invoke("Quit", new Variant[]{});
|
|
|
|
// 如果没有这句话,winword.exe进程将不会关闭
|
|
|
|
ComThread.Release(); |
|
|
|
} |
|
|
|
// 如果没有这句话,winword.exe进程将不会关闭
|
|
|
|
ComThread.Release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|