Click here to Skip to main content
15,916,600 members

Comments by Member 11403220 (Top 3 by date)

Member 11403220 26-Sep-18 5:32am View    
string Pathh = @"";
// Excel.Application excelApp = new Excel.Application();
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkBook = xlApp.Workbooks.Open(Pathh, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, false, false, false);
object misValue = System.Reflection.Missing.Value;
xlWorkBook = xlApp.Workbooks.Add(misValue);


// your code
Worksheet workSheet = (Worksheet)xlWorkBook.Worksheets[2];

Its not working .
Member 11403220 26-Sep-18 2:18am View    
I want to read the sheet 2 and sheet 1 data from same workbook .I tried this way

xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];
xl.Worksheet ws = (xl.Worksheet)wb.Sheets[2];

but any how its showing error for 2nd statement (xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];) bad index error occured.

Can you help me out ??

I want to read both sheets data i.e Sheet1 and Sheet2 both.

Its urgent please help me out.
Member 11403220 26-Sep-18 2:18am View    
I want to read the sheet 2 and sheet 1 data from same workbook .I tried this way

xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];
xl.Worksheet ws = (xl.Worksheet)wb.Sheets[2];

but any how its showing error for 2nd statement (xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1];) bad index error occured.

Can you help me out ??

I want to read both sheets data i.e Sheet1 and Sheet2 both.

Its urgent please help me out.