将两个excel文件合并为java中一个工作簿中的两个工作表

use*_*923 8 java core apache-poi

我在文件夹C:\ DemoFilesExcel\demo1.xlsx和C:\ DemoFilesExcel\demo2.xlsx中有两个xlsx文件.

我想创建一个新的xlsx C:\ DemoFilesExcel\merged.xlsx,它将这两个文件作为merged.xlsx工作簿中的两个工作表.

这是在java中使用apache POI完成的.任何想法怎么做

小智 3

//Open the first excel file.
Workbook SourceBook1 = new Workbook("F:\\Downloads\\charts.xlsx");

//Define the second source book.
//Open the second excel file.
Workbook SourceBook2 = new Workbook("F:\\Downloads\\picture.xlsx");

//Combining the two workbooks
SourceBook1.combine(SourceBook2);

//Save the target book file.
SourceBook1.save("F:\\Downloads\\combined.xlsx");
Run Code Online (Sandbox Code Playgroud)

http://www.aspose.com/docs/display/cellsjava/Combine+Multiple+Workbooks+into+a+Single+Workbook