locked
How export Crystal Report to Text file (.txt) in ASP.net RRS feed

  • Question

  • User910710390 posted

    I want to export crystal report to .txt in vb.net visual studio 2013 , the version crystal decision is 10.5.3700.0 

    and version  my crystal report on machine Crystal Report 11 XI

     

    but I don't find this format type ExportFormatType.Text ,I have ExportFormatType.(PortableDocFormat(.pdf),WordforWindows(.doc),Excel(.xls),ExcelRecord(.xls),RichText(.rtf),.crystalreport,nofrmat,Html40,Html32)

    how can I added  ExportFormatType.Text to visual studio 2013 .

    Can I exported crystal to .txt successfully for design report and data ?

    Please Help me.

    Thank's  

    Tuesday, December 19, 2017 6:59 AM

All replies

  • User-129908252 posted

    Hi Mohammed,

    Please try below code in vb.net

    CrystalDecisions.Shared.ExportFormatType.Text

    or

    Dim MyReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument = ReportName

    Dim Field As CrystalDecisions.Shared.ParameterValues

    Dim Value As CrystalDecisions.Shared.ParameterDiscreteValue

    Try

    If Not ParamName Is Nothing Then

    For i As Integer = 0 To ParamName.Length - 1

    Field = New CrystalDecisions.Shared.ParameterValues

    Value = New CrystalDecisions.Shared.ParameterDiscreteValue

    Value.Value = ParamValues(i)

    Field.Add(Value)

    MyReportDocument.DataDefinition.ParameterFields(ParamName(i)).ApplyCurrentValues(Field)

    Next

    End If

    CrystalDecisions.Shared.ExportOptions.CreateTextFormatOptions.CharactersPerInch = 16

    CrystalDecisions.Shared.ExportOptions.CreateTextFormatOptions.LinesPerPage = 50

    MyReportDocument.ExportToDisk(ExportFormatType.Text, "c:\pleasework1.txt")

    'MyReportDocument.PrintOptions.PrinterName = ""

    'MyReportDocument.PrintToPrinter(1, True, 0, 0)

    Catch ex As Exception

    MsgBox(ex.Message, MsgBoxStyle.OKOnly, "Print Report")

    Finally

    MyReportDocument.Close()

    MyReportDocument.Dispose()

    End Try

    End Sub

    If you got solution, please mark it as my asnwer.

    Thanks,

    Jagan

    Monday, December 25, 2017 10:59 AM
  • User-1812164866 posted

    Hello, You could probably use a console app or a forms app but just don't display the form. I tend to point people to the code samples at: http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm | Crystal Reports

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class Form1
        Dim cryRpt As New ReportDocument
    
        Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
            cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
            CrystalReportViewer1.ReportSource = cryRpt
            CrystalReportViewer1.Refresh()
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button2.Click
            Try
                Dim CrExportOptions As ExportOptions
                Dim CrDiskFileDestinationOptions As New _
                DiskFileDestinationOptions()
                Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
                CrDiskFileDestinationOptions.DiskFileName = _
                                            "c:\crystalExport.pdf"
                CrExportOptions = cryRpt.ExportOptions
                With CrExportOptions
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    .ExportFormatType = ExportFormatType.PortableDocFormat
                    .DestinationOptions = CrDiskFileDestinationOptions
                    .FormatOptions = CrFormatTypeOptions
                End With
                cryRpt.Export()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End Sub
    End Class

    Thanks
    James Mason

    Thursday, January 4, 2018 6:08 AM