在Java中的一个工作簿中将两个Excel文件合并为两个工作表 [英] Merging Two excel files as two sheets in one workbook in java

查看:1249
本文介绍了在Java中的一个工作簿中将两个Excel文件合并为两个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have two xlsx files at folder C:\DemoFilesExcel\demo1.xlsx and C:\DemoFilesExcel\demo2.xlsx.

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

I want to create a new xlsx C:\DemoFilesExcel\merged.xlsx that will have these two files as two sheets in merged.xlsx workbook.

这将在Java中使用apache POI完成.任何想法怎么做

This is to be done using apache POI in java. Any idea how to do

推荐答案

//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");

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

这篇关于在Java中的一个工作簿中将两个Excel文件合并为两个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆