首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

施用jacob 合并excel

2012-08-22 
使用jacob 合并excel使用jacob 合并excel??try {??? ??? ??? ??? ??? ??? String tempDir System.getPro

使用jacob 合并excel

使用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();
??? ??? }

热点排行