We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding Worksheets in Certain Order

The program I'm using is creating worksheets as needed. The worksheet needs to be added at the end of the excel.

the only thing I can find about adding worksheets is .


There is no overload that I can see in the Add. Is there a way to add new worksheets to the end of the document?



Well, when you use: wrkBook.Worksheets.Add(aName); the new worksheets are added at the end in the workbook. There are a list of valuable methods in Aspose.Cells for .NET API that you can make use of them:

1) To move a worksheet --------- Worksheet.Move() can be used to move a worksheet to other indexed position in a workbook.
2) To get the index of a worksheet ---------- Worksheet.Index attribute can be used.
3) To add worksheet -------Worksheets.Add() can be used. The new worksheet would added at the end position in the workbook.
4) To add an existing copy of a worksheet ----------- Worksheets.AddCopy() method can be used.
5) To insert a worksheet at some indexed position ------------------Worksheet.Insert() method can be used (This is a new api, you need to use latest fix e.g or later)
6) To Remove a Worksheet ----- Worksheets.RemoveAt() method can be
used to remove a single worksheet at specific indexed position,
7) To remove all the worksheets in a workbook --------------Worksheets.Clear() method can be used.

Kindly let us know if you need further clarifications, we would be happy to asisst you.

Thank you.