C#: Online Guide
How To: excel SDK
File: Merge Excel Files
File: Merge Excel Files
  |  
Home ›› XDoc.Excel ›› C# Excel: Merge Excel Files

C# Excel - Merge Excel Documents in C#.NET


Provide C# Demo Codes for Merging and Appending Excel Document




Overview



RasterEdge C#.NET Excel document merging toolkit (XDoc.Excel) is designed to help .NET developers combine Excel document files created by different users to one Excel file. Thus, C#.NET Excel document merge library control can be counted as an efficient .NET doc solution for keeping Excel document files organized.


Related .net document control helps:
asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service
asp.net edit pdf image: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net convert pdf: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net word document viewer: ASP.NET Office Word Document Viewer: view MS Office Word files online using C# in ASP.NET web applications
asp.net webforms document viewer: ASP.NET WebForms application document viewer control: view, annotate, redact, convert files online in ASP.NET
document redact asp.net: Redact document ASP.NET: add, delete, apply redaction on PDF files in web browser using C#.net
asp.net pdf file permission: ASP.NET PDF File Permission Control: apply, remove PDF file permission settings in C#


This C# .NET Excel document merging control is written in managed C# code and compatible with all .NET developing platforms, like ASP.NET web application and Windows Forms project. Using this Excel document concatenating library SDK, C# developers can easily merge and append one Excel document to another Excel document file, and choose to create a new Excel file in .NET class application.


Besides C#.NET Excel document merging function, XDoc.Excel, a professional third-party .NET document imaging toolkit, also offers other advanced Excel document page processing and manipulating functions, such as Excel page insertion, Excel page deleting, Excel document splitting, Excel page reordering and Excel page image and text extraction. Remarkably, all those C#.NET Excel document page processing functions can be implemented independently, without using any Adobe-related software.


Our .NET Excel SDK empowers C# programmers to easily merge and append Excel files with mature APIs. To be more specific, two or more input Excel documents can be merged and appended together according to its loading sequence, and then saved and output as a single Excel with user-defined location.




C# DLLs: Merge Excel Files



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Excel.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Using namespaces:


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Excel;




Combine and Merge Multiple Excel Files into One Using C#



This part illustrates how to combine three Excel files into a new file in C# application. You may also combine more Excel documents together.




String inputFilePath1 = Program.RootPath + "\\" + "1.xlsx";
String inputFilePath2 = Program.RootPath + "\\" + "2.xlsx";
String inputFilePath3 = Program.RootPath + "\\" + "3.xlsx";
String outputFilePath = Program.RootPath + "\\" + "Output.xlsx";
String[] inputFilePaths = new String[3] { inputFilePath1, inputFilePath2, inputFilePath3 };

// Combine three Excel files and output.
XLSXDocument.CombineDocument(inputFilePaths, outputFilePath);





Append Excel Document in C#



In addition, C# users can append a Excel file to the end of a current Excel document and combine to a single Excel file.




//  get XLSXDocument object from one file
String inputFilePath1 = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc1 = new XLSXDocument(inputFilePath1);
//  get XLSXDocument object from another file
String inputFilePath2 = Program.RootPath + "\\" + "2.xlsx";
XLSXDocument doc2 = new XLSXDocument(inputFilePath2);

//  append the 2nd document
doc1.AppendDocument(doc2);

//  save the document
String outputFilePath = Program.RootPath + "\\" + "Output.xlsx";
doc1.Save(outputFilePath);