Dear Friends Can any body help me .. i want to export my crystal report to a text file, here is my code. If its not good then please give any other perfect refrence thank you

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Diagnostics
Imports System.IO


Public Class Form1
    Dim myReportDocument As New ReportDocument
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        myReportDocument.Load("d:\test\S111.rpt")
        CrystalReportViewer1.ReportSource = myReportDocument
        CrystalReportViewer1.Refresh()


    End Sub

    Private Sub BtnText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnText.Click


        Try
            Dim CrExportOptions As ExportOptions
            Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
            Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions


            CrDiskFileDestinationOptions.DiskFileName = "c:\check.txt"
            CrExportOptions = myReportDocument.ExportOptions
            With CrExportOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With
            myReportDocument.Export()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub



End Class

I am using VS.NET 2008 and crystal report 8.5

Why do you want to export crystal reports to a text file?

There's no option for .txt in CR, but, you can still get a bad version of .txt if you want.

        Try
            Dim CrExportOptions As ExportOptions
            Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
            Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
            CrDiskFileDestinationOptions.DiskFileName = "YourDestination"
            CrExportOptions = myReportDocument.ExportOptions
            With CrExportOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.RichText
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With
            myReportDocument.Export()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

becuase after export we want to do some more analaysis operation on DAT which is posisble in text file

Eternal ... It is rich text .. RTF not text version .. i need in txt form .. data.txt ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.