locked
Import Excel Sheet from ASP.Net RRS feed

  • Question

  • User-1620825299 posted

     hi all,

    i'm importing a excel file from asp.net page using oledb. the file contain some unicode charecters like &yelm; etc. the sheet have some text column, date column and integer columns.  the problem is that when i'm fetching the recods from excel sheet then its not fatching all the records.its not fetching some column's value.

    this is my connection string

    objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source="+filename+"; Extended Properties=" +(char)34 + "Excel 8.0; HDR=Yes; IMEX=1" + (char)34);

     

    kindly help me

     

    thanks 

     

    Thursday, January 8, 2009 5:17 AM

Answers

  • User-1171043462 posted

    You can refer to my post I have placed the complete function here http://forums.asp.net/p/1365129/2833208.aspx#2833208

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 8, 2009 9:31 AM
  • User915387828 posted

    Hi suhaib.faizy,

    You can use OleDb to implement it.

    Protected Sub btnGenerateReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerateReport.Click
    Try
     
    Dim strExcelConn As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ExcelConnection").ToString()
    Dim dbConn As New OleDbConnection(strExcelConn)
    Dim strSQL As String
     
    strSQL = "SELECT S.StudentId, S.StudentName, M.Marks, G.Marks, (M.Marks+G.Marks) AS Total "& _
                         "FROM [Students$] S, [Mathematics$] M, [Geography$] G "& _
                         "WHERE(S.StudentId = M.StudentId And S.StudentId = G.StudentId) " & _
                         "ORDER BY (M.Marks+G.Marks) DESC"
    dbConn.Open()
     
    Dim cmd As New OleDbCommand(strSQL, dbConn)
    Dim dsExcel As New DataSet
    Dim daExcel As New OleDbDataAdapter(cmd)
     
    daExcel.Fill(dsExcel)
     
    dgReports.DataSource = dsExcel
    dgReports.DataBind()
     
    Catch ex As Exception
    Throw ex
    End Try
    End Sub

    Please check the following link.

    http://www.beansoftware.com/asp.net-tutorials/generating-excel-reports.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 11, 2009 10:27 PM

All replies

  • User-1171043462 posted

    You can refer to my post I have placed the complete function here http://forums.asp.net/p/1365129/2833208.aspx#2833208

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 8, 2009 9:31 AM
  • User915387828 posted

    Hi suhaib.faizy,

    You can use OleDb to implement it.

    Protected Sub btnGenerateReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerateReport.Click
    Try
     
    Dim strExcelConn As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ExcelConnection").ToString()
    Dim dbConn As New OleDbConnection(strExcelConn)
    Dim strSQL As String
     
    strSQL = "SELECT S.StudentId, S.StudentName, M.Marks, G.Marks, (M.Marks+G.Marks) AS Total "& _
                         "FROM [Students$] S, [Mathematics$] M, [Geography$] G "& _
                         "WHERE(S.StudentId = M.StudentId And S.StudentId = G.StudentId) " & _
                         "ORDER BY (M.Marks+G.Marks) DESC"
    dbConn.Open()
     
    Dim cmd As New OleDbCommand(strSQL, dbConn)
    Dim dsExcel As New DataSet
    Dim daExcel As New OleDbDataAdapter(cmd)
     
    daExcel.Fill(dsExcel)
     
    dgReports.DataSource = dsExcel
    dgReports.DataBind()
     
    Catch ex As Exception
    Throw ex
    End Try
    End Sub

    Please check the following link.

    http://www.beansoftware.com/asp.net-tutorials/generating-excel-reports.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 11, 2009 10:27 PM