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

Free Support Forum - aspose.com

Aspose.cells adding new sheet to the exel

Hello,

How can i add the sheet2 for the already avilable workbook.

by using

Worksheet worksheetEvalExtract = workbookEvalExtract.Worksheets[0]; -- till now we have only sheet1 and it is working fine

now, it is a new requiement to export the data to SHeet2 as well along wih sheet1 information, i try to develop the follwoing code, it is not working,

Worksheet worksheetEvalExtract1 = workbookEvalExtract.Worksheets[1];

we need to get the export to excel without using template.

Regards,

Anusha VALLABHANENI

Hi,


Thanks for providing us some details.

Well, when you instantiate a new workbook, it only has one worksheet (default sheet named “Sheet1”). Now, if you need to get second worksheet, I am afraid, you have to add it to the workbook first. See the sample line of code which you should add before your line of code:
e.g
Sample code:

workbookEvalExtract.Worksheets.Add();
Worksheet worksheetEvalExtract1 = workbookEvalExtract.Worksheets[1];//Get the second sheet in the workbook.

Please see the document for your complete reference:
http://www.aspose.com/docs/display/cellsnet/Manage+Worksheets

Hope, this helps a bit.

Thank you.