Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created January 14, 2021 05:57
Show Gist options
  • Save conholdate-gists/93009b8b055b086b90ee581d40ad5b73 to your computer and use it in GitHub Desktop.
Save conholdate-gists/93009b8b055b086b90ee581d40ad5b73 to your computer and use it in GitHub Desktop.
Combine Multiple Excel Files into One using C#
// Open the first excel file.
Workbook SourceBook1 = new Workbook("Excel A.xlsx");
// Open the second excel file.
Workbook SourceBook2 = new Workbook("Excel B.xlsx");
// Open the third excel file.
Workbook SourceBook3 = new Workbook("Excel C.xlsx");
// Copy worksheets of second Excel file to the first workbook.
SourceBook1.Combine(SourceBook2);
// Copy worksheets of third Excel file to the first workbook.
SourceBook1.Combine(SourceBook3);
// Save the updated first excel file as a new file.
SourceBook1.Save("CombinedFile.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment