C#: Online Guide
How To: excel SDK
Page: Extract Excel Pages
Page: Extract Excel Pages
Home ›› XDoc.Excel ›› C# Excel: Extract Excel Pages

C# Excel - Extract or Copy Excel Pages to Excel File in C#.NET

Extract/Copy Excel Pages of Excel Document in C# Project


The Microsoft Office Excel, known as Excel document, is a widely-used form of file that allows users to open & read documents even though they are using different types of Excel processors. Besides, the capacity to be locked against editing or processing by others makes Excel file become increasingly popular among large enterprises and organizations.

Related .net document control helps:
asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
asp.net redact pdf: ASP.NET Redact PDF Document Control: redact, remove PDF text, images in web browser using C# ASP.NET
asp.net mvc pdf editor: ASP.NET MVC PDF Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net open pdf password: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#
asp.net create pdf: ASP.NET Create PDF Document Control: create, convert PDF file from Word, Excel, Tiff file formats in C# ASP.NET
asp.net azure pdf editor: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
asp.net document viewer: ASP.NET Document Viewer Control in C#: View, Annotate, Redact web document files in ASP.NET using C#

Using this C#.NET Excel document page extract library control, developers can extract pages from Excel document. Using the library, you should be sure that the page index is valid.

C# DLLs: Excel Page Extraction

Add necessary references:










Using namespaces:

  using RasterEdge.Imaging.Basic;

  using RasterEdge.XDoc.Excel;

Extract Excel Pages Using C#

You may choose extract pages of Excel file and save to Excel file.

XLSXDocument doc = new XLSXDocument(@"C:\1.xlsx");
int[] pageIndexes = new int[] { 1, 3};
doc.ExtractPages(pageIndexes, @"C:\extract.xlsx");

Copy Excel Pages and Append to Another Excel File Using C#

You may copy pages of Excel file and paste to another Excel file.

XLSXDocument doc = new XLSXDocument(@"C:\1.xlsx");
int[] pageIndexes = new int[] { 1, 3};
Stream stream = new MemoryStream();
//extract pages to stream
doc.ExtractPages(pageIndexes, stream);
FileStream fileStream = File.Open(@"C:\2.xlsx", FileMode.Open);
//paste the pages extracted to second word file
XLSXDocument.CombineDocument(new Stream[] { stream, fileStream }, @"C:\copy.xlsx");