Reorder Worksheets
Contents
[
Hide
]
Aspose.Cells - Reorder Worksheets
C#
//Create a new Workbook.
Workbook workbook = new Workbook();
WorksheetCollection worksheets = workbook.Worksheets;
Worksheet worksheet1 = worksheets[0];
Worksheet worksheet2 = worksheets.Add("Sheet2");
Worksheet worksheet3 = worksheets.Add("Sheet3");
//Move Sheets with in Workbook.
worksheet2.MoveTo(0);
worksheet1.MoveTo(1);
worksheet3.MoveTo(2);
//Save the excel file.
workbook.Save("../../data/AsposeMoveSheet.xls");
NPOI - HSSF XSSF - Reorder Worksheets
C#
IWorkbook wb = new XSSFWorkbook();
wb.CreateSheet("new sheet");
wb.CreateSheet("second sheet");
wb.CreateSheet("third sheet");
wb.SetSheetOrder("second sheet", 0);
wb.SetSheetOrder("new sheet", 1);
wb.SetSheetOrder("third sheet", 2);
FileStream sw = File.Create("../../data/Reordered.xls");
wb.Write(sw);
sw.Close();
Download Running Code
Download Reorder Worksheets form any of the below mentioned social coding sites:
For more details, visit Working with Worksheets.