This project has moved and is read-only. For the latest updates, please go here.

How can i select 2 sheets i Excel ?

Sep 11, 2012 at 1:04 PM


I want select 2 sheets.

And how can i display excel instance ?

 My code

Excel.Application excelApplication = new Excel.Application();
excelApplication.DisplayAlerts = false;
Excel.Workbook workBook = excelApplication.Workbooks.Open(@"D:\PROJETS.NET\BOVICAP-GCP\ApplicationPoubelle\Templates\Lait2013.xlsx");

Excel.Worksheet workSheet1 = (Excel.Worksheet)workBook.Worksheets["mysheet-1"];
Excel.Worksheet workSheet2 = (Excel.Worksheet)workBook.Worksheets["mysheet-2"];

List<Excel.Worksheet> sheetList = new List<Excel.Worksheet>();

workBook.Worksheets.SelectMany(f => sheetList);

Best regards

Sep 11, 2012 at 3:36 PM
Edited Sep 11, 2012 at 3:36 PM

Question: And how can i display excel instance ?


excelApplication.Visible = true;
Sep 12, 2012 at 2:16 PM

you can loop over the worksheets enumerator and select any worksheet step by step or you can use the Select method from the Sheets collection with a string array parameter. SelectMany is linq specific stuff and not helpfull here.