C#: Online Guide
How To: excel SDK
Page: Move Excel Page Position
Page: Move Excel Page Position
  |  
Home ›› XDoc.Excel ›› C# Excel: Move Excel Page Position

C# Excel - Sort Excel Pages Order in C#.NET


Support Customizing Page Order of Excel Document in C# Project




Overview



RasterEdge C#.NET Excel document page reordering control SDK (XDoc.Excel) is a thread-safe .NET library that can be used to adjust the Excel document pages order. This Excel document page reorganizing control condenses quick Excel page sorting functions into a compact library, which is compatible with .NET-compliant programming language C#.


Related .net document control helps:
asp.net sharepoint document viewer: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
asp.net powerpoint document viewer: ASP.NET PowerPoint Document Viewer Control: view pptx files online in C# using ASP.NET
asp.net document viewer: ASP.NET Document Viewer Control in C#: View, Annotate, Redact web document files in ASP.NET using C#
asp.net sharepoint pdf editor: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites
asp.net azure pdf editor: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
asp.net dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET


Using this C#.NET Excel document page reorganizing library control, developers can swap or adjust the order of all or several Excel document pages, or just change the position of certain one Excel page in an extremely easy and quick way using C# code.


Besides C#.NET Excel document page sorting function, RasterEdge has also offered other .NET Excel page processing functions, like Excel documents merging, Excel page rotating, Excel image extracting, Excel page inserting, Excel page deleting and Excel document splitting.




C# DLLs: Move Excel Page Position



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;




Swap Two Excel Pages Position Using C#



You may choose two pages of Excel file and exchange their position.



String filepath = @"";
String outPutFilePath = @"";
XLSXDocument doc = new XLSXDocument(filepath);

// Swap page 0 and page 1.
doc.SwapTwoPages(0, 1);

// Save Excel document.
doc.Save(outPutFilePath);





Sort Multiple Excel Pages with a Certain Order in C#.NET


Use C# sample code below to sort several pages of Excel file to your desired order.



//  get XLSXDocument object from a source file
String inputFilePath = Program.RootPath + "\\" + "1.xlsx";
XLSXDocument doc = new XLSXDocument(inputFilePath);

//  show page count of the document
int pageCount = doc.GetPageCount();
Console.WriteLine("Page Count: " + pageCount);

//  define the new order for all pages
//  1. the length of the array MUST BE equal to pageCount
//  2. each page index SHOULD be in the array and only once
//  otherwise, the method would throw exception
int[] pageOrders = new int[] { 1, 3, 0, 5, 4, 6, 2 };
doc.SortPage(pageOrders);

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