Export Crystal Report in Microsoft Excel

  •  Dim sConnectionString As String = "Provider=SQLOLEDB;Data Source=servername;Initial Catalog=databasename;Persist Security Info=True;User ID=sa;Password=123;Max Pool Size=1000"

    Dim con As New OleDb.OleDbConnection(sConnectionString)


    Dim cmd As New OleDb.OleDbCommand("select * from ReportMarks where [Login]='manager'", con)
    Dim da As New OleDb.OleDbDataAdapter(cmd)

    Dim DT As New DataTable

    Dim report As New ReportDocument()
    Dim reportfileName As String = "CRSReportMarks.rpt"

      Dim path As String = "Specify the path"

    report.Load(path & reportfileName)

    Dim fileName As String = "SubCategoryReport"

    Dim exportFilePath As String = Server.MapPath("~/Reports/" & fileName & ".xls")
    Dim oDest As DiskFileDestinationOptions
    Dim oExport As ExportOptions

    oDest = New DiskFileDestinationOptions()

    oDest.DiskFileName = exportFilePath
    oExport = report.ExportOptions

    oExport.DestinationOptions = oDest

    oExport.ExportDestinationType = ExportDestinationType.DiskFile

    oExport.ExportFormatType = ExportFormatType.Excel



Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week