How to read particular excel sheet using Excel Data Reader

Apr 30, 2013 at 8:57 AM
Edited Apr 30, 2013 at 10:45 AM

Thanks a lot. This is working great. I having an excel file having about 10 sheet's. but I need to read data from three sheets alone. I don't want to read rest of the sheets. Is there any better way to do this? I need to do this coz, I'm optimizing the performance in my application.

Thanks in advance.

Apr 30, 2013 at 11:59 AM
You are probably best using the IDataReader interface rather than the AsDataset method on IExcelDataReader. That way you can skip over sheets you aren't interested in with the NextResult method.
Apr 30, 2013 at 12:35 PM
Edited Apr 30, 2013 at 12:43 PM
Thanks Ian for the answer.

I have inherited the source code and added a overloaded method AsDataSet(string sheetName) to read specific sheet.
and checking this condition in the foreach of the sheet reading. if (sheetName != _workbook.Sheets[ind].Name)) continue;