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

查看:61
本文介绍了在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天全站免登陆