Free Support Forum - aspose.com

How to delete a worksheet in a workbook/excel file?

dear sir: i study aspose cells recently . and i don't know how to delete a worksheet in

a workbook/excel file by aspose cells ! please tell me! thank you!

hehe . i think this question maybe native !

don't laugh at me ! ~~

alpha

Hi,

Thanks for considering Aspose.

Well you may use Worksheets.RemoveAt() method to delete any worksheet in the workbook.

Following is a sample code:

Workbook workbook = new Workbook();

workbook.Open(@"d:\bk1.xls");

// Removes the first sheet in the workbook.

workbook.Worksheets.RemoveAt(0);

workbook.Save(@"d:\bk1.xls");

For reference, please see:

http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/ManagingWorksheets.html

Regards

Amjad Sahi

Aspose Nanjing Team

        thank you very much!