aceminer
aceminer

Reputation: 4295

Excel not writing to specific sheet

I have tried googling but it doesnt seem to help

Excel.Application excelApp = new Excel.Application();
Excel.Workbook output_workbook = excelApp.workbooks.Add(misvalue);
Excel.Worksheet output = output_workbook.Sheets.getItem(2);
output.Activate();

//do something here
output.Cells[1,1] = "" 

It seems i have hard coded it to be the second sheet but it seems it stills give me the first sheet.

I have tried other methods like

output = output.WorkSheets[2]; it still doesnt work

Upvotes: 0

Views: 508

Answers (1)

Lift
Lift

Reputation: 546

Try this instead:

Excel.Worksheet output = output_workbook.Worksheets.getItem(2);

I use Worksheets.getItem(value); and it works fine.

Upvotes: 2

Related Questions