I have a xlsx file like (it is the first sheet)
Postcode Sales_Rep_ID Sales_Rep_Name Year Value
2121 456 Jane 2011 $84,219
2092 789 Ashish 2012 $28,322
2128 456 Janet 2013 $81,879
2073 123 John 2011 $44,491
How do I get a particular value of the column named Year whose say, Sales_Rep_Name value is Janet? I'm stuck at the below code and can't figure how to do it?
FileStream stream = File.Open(@"C:\Users\Bumba\Downloads\Sample-Sales-Data.xlsx", FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet(new ExcelDataSetConfiguration() {
ConfigureDataTable = (_) => new ExcelDataTableConfiguration() {
UseHeaderRow = true
}
});
foreach (DataTable element in result.Tables) {
Console.WriteLine(element.Columns["Year"].ToString());
//what to do??????
}
excelReader.Close();
Console.ReadLine();
Someone help....
Sales_Rep_Nameis your search criteria and from there find the cell value you want is a valid approach here?