Merge files into single workbook

We are trying to merge 2 or more .xlsx file into a single workbook with multiple sheets (one for each sheet in the input workbook files).


There is an example program in the \Aspose.Cells-for-.NET-master\Examples\Data\CellsHelperClass\MergeFiles folder with the following code snippet:

// Merge the files in the output file. Supports only .xls files
CellsHelper.MergeFiles(files, cacheFile, dest);

the problem is it only supports .xls files. Is there a way to do this for .xlsx files as well?

Thanks.

Hi Ronny,


Thank you for contacting Aspose support.

You can use Workbook.Combine method for your requirement. Please check the following piece of code for reference.

C#

Workbook book1 = new Workbook(dir + “sample1.xlsx”);
Workbook book2 = new Workbook(dir + “sample2.xlsx”);
book1.Combine(book2);
book1.Save(dir + “combined.xlsx”);