Combine Multiple Workbooks into a Single Workbook

Combining Workbooks with Images and Charts

The example code combines two workbooks into a single workbook using Aspose.Cells. The code loads the source workbooks, uses the Workbook.combine() method to combine them and saves the output workbook.

Source Workbooks

Output Workbooks

Screenshots

Below are screenshots of the source and output workbooks.

The first worksheet of the charts workbook - stacked

todo:image_alt_text

Second worksheet of charts workbook - line

todo:image_alt_text

First worksheet of the picture workbook - picture

todo:image_alt_text

All three worksheets in the combined workbook - stacked, line, picture

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Define the first source
// Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");
// Define the second source book.
// Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");
// Combining the two workbooks
SourceBook1.Combine(SourceBook2);
dataDir = dataDir + "Combined.out.xlsx";
// Save the target book file.
SourceBook1.Save(dataDir);

Advance topics