使用jacob 合并excel
try {
String tempDir = System.getProperty("java.io.tmpdir");
ActiveXComponent excel = new ActiveXComponent("Excel.Application");
Dispatch workbooks = excel.getProperty("Workbooks").toDispatch();
Dispatch workbook = Dispatch.call(
workbooks,
"Open","master.xls" ).toDispatch();
Variant[] vargs = new Variant[copyFromFilesArray.length + 2];
vargs[0] = new Variant("Sheet1.CombineWorkbooks");
SequenceUUID oGeneration = SequenceUUID.getInstance();
String tempFile = tempDir + oGeneration.getUUID() + ".xls";
vargs[1] = new Variant(tempFile);
for (int i = 0; i < copyFromFilesArray.length; i++) {
vargs[i + 2] = new Variant(copyFromFilesArray[i]);
}
Dispatch.call(excel, "Run", vargs);
return tempFile;
} finally {
ComThread.Release();
}