string HDR = hasHeaders ? "Yes" : "No";
string constr ;
if (FileName.Substring(FileName.LastIndexOf('.')).ToLower() == ".xlsx")
constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
else
constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";