Get only Excel column names in C#
- by Newbie
Is there any easy way apart from
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+fileName+";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";
using (objConn = new OleDbConnection(ConnectionString))
{
objConn.Open();
Logger.Info("Reading the file "+fileName+"....");
objCmdSelect = new OleDbCommand("SELECT * FROM [" + sheetName + "$] WHERE 0 = 1", objConn);
objAdapter = new OleDbDataAdapter();
objAdapter.SelectCommand = objCmdSelect;
objDataset = new DataSet();
Logger.Info("Filling the dataset....");
objAdapter.Fill(objDataset, fileName);
Logger.Info("Returning the dataset....");
return objDataset;
}
and then looping the datatables
for getting the excel column names given a filename and sheet name?
Using C#(and no interop services)
Thanks