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

C# Excel - Split Excel Document in C#.NET


Explain How to Split Excel Document in Visual C#.NET Application




Overview



C# Excel document splitting library control, XDoc.Excel, provides an advanced C# programming way to split Excel document into smaller Excel files in .NET developing applications. how to create password protected pdf file in c#, print mvc view to pdf, vb.net pdf print library, vb.net barcode reader from image, mvc export to pdf, c# datamatrix reader. Using this C#.NET Excel document splitting library control, C# developers can easily and accurately disassemble multi-page Excel document into two or more separate Excel document files by page(s).


Related .net document control helps:
asp.net annotate pdf using c#: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
c# asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net mvc pdf editor control: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net sharepoint document viewer control: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net view text file in browser: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
asp.net edit pdf image using c#: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net mvc word viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications


RasterEdge Visual C# .NET Excel document splitter control toolkit SDK can not only offer C# developers a professional .NET solution to split Excel document file but also provide them the ability to name outputted Excel document files with a customized name pattern using a few lines of simple Visual C# code. how to make a pdf of a page in c#, convert pdf to text c#, c# resize pdf file, pdf to thumbnail converter c#, c# pdf number of pages, vb net pdf compress and resize free, c# pdf parse table.


This C#.NET Excel document splitting library control offers developers an efficient Excel document splitting approach, using which C# developers can split target Excel document file by specifying a page or pages. asp.net mvc display pdf, asp.net show excel file in browser, asp.net pdf viewer control, preview pdf in asp.net, how to write pdf file in asp.net c#, asp.net remove image from pdf file, asp.net core image viewer. If needed, developers can also combine generated split Excel document files with other Excel files to form a new Excel file using RasterEdge XDoc.Excel. Besides, in the process of splitting Excel document, developers can also remove certain Excel page from target Excel file using C#.NET Excel page deletion API.


Please note, Excel file will be divided from the previous page of your defined page number which starts from 0. For example, your original Excel file contains 4 pages. If your page number is set as 1, then the two output Excel files will contains the first page and the later three pages respectively.




C# DLLs: Split Excel Document



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;




Split Excel file into two files in C#



This is an C# example of splitting a Excel file into multiple ones by number of pages.




String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
String outputFilePath1 = Program.RootPath + "\\" + "Split1.xlsx";
String outputFilePath2 = Program.RootPath + "\\" + "Split2.xlsx";
String[] outputOps = new  String[] { outputFilePath1, outputFilePath2 };
//  split a Excel file with options
XLSXDocument.SplitDocument(inputFilePath, 2, outputOps);





Split Excel Document into Multiple Excel Files in C#



You can use the following C# demo to split Excel document to four files.




String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
String outputFileName = "Output.xlsx";
int[] splitIndex = new int[3] { 1, 3, 5 }; // Valid value for each index: 1 to (Page Count - 1).

// Create output Excel file path list
List<String> outputFilePaths = new List<String>();
for (int i = 0; i <= splitIndex.Length; i++)
{
        outputFilePaths.Add(Program.RootPath + "\\" + outputFileName + "_" + i.ToString() + ".xlsx");
}

// Split input Excel file to 4 files:
// File 0: page 0.
// File 1: page 1 ~ 2.
// File 2: page 3 ~ 4.
// File 3: page 5 ~ the last page.
XLSXDocument.SplitDocument(inputFilePath, splitIndex, outputFilePaths.ToArray());