Regarding Importing excel file to asp.net page
-
i have exported file to Excel......nw i need to retrieve the same excel file to my asp.net application My excel file is like the given below :- AssetID Description AssetTag 1246 hello me(1246) 10103001245 1247 hi me(1247) 10103001246 when am trying to import, am getting an error like " External table is not in the expected format " wht might be the prblm..... can anyone help me?
-
i have exported file to Excel......nw i need to retrieve the same excel file to my asp.net application My excel file is like the given below :- AssetID Description AssetTag 1246 hello me(1246) 10103001245 1247 hi me(1247) 10103001246 when am trying to import, am getting an error like " External table is not in the expected format " wht might be the prblm..... can anyone help me?
add this code Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment;filename=DCNReport.xls"); Response.Charset = ""; this.EnableViewState = false;
r_palanivel83 10:01 4 Jan '06
-
add this code Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment;filename=DCNReport.xls"); Response.Charset = ""; this.EnableViewState = false;
r_palanivel83 10:01 4 Jan '06
This is for while exporting the file..... my code is like ths:- Dim excelname As String = FileUpload1.PostedFile.FileName Dim intFileNameLength As Integer = InStr(1, StrReverse(excelname), "\") strFileName = Mid(excelname, (Len(excelname) - intFileNameLength) + 2) Dim namewe As String = System.IO.Path.GetFileNameWithoutExtension(strFileName) Dim sWorkbook As String = namewe + "$" FileUpload1.PostedFile.SaveAs(Server.MapPath("ImportFiles/") + namewe + ".xls") Dim oledbconn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("ImportFiles/") + namewe + ".xls ;Extended Properties=Excel 8.0;") Comm.CommandText = "SELECT AssetID,Description,AssetTag FROM [" & sWorkbook & "]" Comm.CommandType = Data.CommandType.Text Comm.Connection = oledbconn oledbadap.SelectCommand = Comm oledbadap.Fill(oledbdatatbl) GrdImpScanner.DataSource = oledbdatatbl.DefaultView GrdImpScanner.DataBind() am getting the error in this line :- " oledbadap.Fill(oledbdatatbl) "