public static File saveAs(String srcFilePath, String destFilePath) {
File destFile = null;
// COM组件初始化
ComThread.InitSTA();
// 打开Excel程序
ActiveXComponent xl = new ActiveXComponent("Excel.Application");
try {
// 不显示程序
Dispatch.put(xl, "Visible", new Variant(false));
// 打开工作簿
Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
Dispatch workbook = Dispatch.call(workbooks,// 执行命令的对象
"Open", // 要执行的命令
srcFilePath,// 要打开的文件
false,// ConfirmConversions
true // ReadOnly
).toDispatch();
// 另存为(数字18表示保存文件版本是Microsoft Excel 97-2003)
Dispatch.invoke(
workbook,
"SaveAs",
Dispatch.Method,
new Object[] {destFilePath, new Variant(18) },
new int[1]);
Dispatch.call(workbook, "Close", new Variant(false));
// 返回另存为文件对象
destFile = new File(destFilePath);
if (!destFile.exists()) {
thr