sravas
sravas

Reputation: 41

Multiple Excel Sheets in One Excel File

I would like to create 4 sheets in xlWorkbook;

     private void btnExportExcel_Click(object sender, EventArgs e)
           {           
           Excel.Application xlApp;
           Excel.Workbook  xlWorkbook;
           Excel.Worksheet xlWorkSheet;
           xlWorkSheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
                  // Code Logic 
           }

I tried

          Excel.Worksheet xlWorkSheet2;
          xlWorkSheet2 = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(2);

But doesn't work out. Could any one help me

Upvotes: 0

Views: 85

Answers (1)

Phil N DeBlanc
Phil N DeBlanc

Reputation: 398

I got this from here:

Excel.Worksheet xlWorkSheet2;
xlWorkSheet2 = (Excel.Worksheet)xlWorkbook.Worksheets.Add();

Do this four times, and you'll get 4 sheets.

Upvotes: 3

Related Questions