I have an Excel file, In which i will have to parse the file in such a way that It should find the Exact sheet and In that Exact text which we are looking. then it should read the text related Checkbox whether it is checked/not. Using c# not Vba.
protected void Page_Load(object sender, EventArgs e)
{
SearchResult();
}
private void SearchResult()
{
try
{
System.Data.OleDb.OleDbConnection MyConnection;
System.Data.DataSet DtSet;
System.Data.OleDb.OleDbDataAdapter MyCommand;
MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='\\XXX\\XXX\\XX\\Excelfiename.xlsx';Extended Properties=Excel 12.0;");
MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [SheetName$]", MyConnection);
MyCommand.TableMappings.Add("Table", "TestTable");
DtSet = new System.Data.DataSet();
MyCommand.Fill(DtSet);
dataGridView1.DataSource = DtSet.Tables[0];
MyConnection.Close();
int j = 38;
for (int i = 0; i < DtSet.Tables[0].Rows.Count; i++)
{
if (DtSet.Tables[0].Rows[j].ItemArray.Contains("Result"))
{
if (DtSet.Tables[0].Rows[j].ItemArray.Contains("PASSED"))
{
Console.WriteLine("PASSED");
}
else if (DtSet.Tables[0].Rows[j].ItemArray.Contains("FAILED"))
{
}
else if (DtSet.Tables[0].Rows[j].ItemArray.Contains("not possible"))
{
}
}
}
}
catch (Exception ex)
{
}
}