string dirpath = Server.MapPath("~") + "uploadfile\\"; string LocalFilePath = dirpath + fileName; fileUpload.PostedFile.SaveAs(LocalFilePath); string fileType = Path.GetExtension(fileName); string SourceConstr = string.Empty; var Inputs = ProjectAttributeMasterService.GetInputAttributes(7); if (fileType == ".xls" || fileType == ".xlsx") { if (fileType == ".xls") { SourceConstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + LocalFilePath + "';;Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'"; } OleDbConnection con = new OleDbConnection(SourceConstr); con.ResetState(); con.Open(); System.Data.DataTable dtl = new DataTable(); System.Data.DataTable dts = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con); da.Fill(dtl); if ((dtl.Rows.Count >= 1 || dtl.Columns.Count >= 1) && !dtl.Columns.Contains("F1")) { } else { /empty file }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)