locked
Crystal Reports export to Text RRS feed

  • Question

  • I have Crystal Report XI r2 and vs2005.

    How to export the report to text instead of to ,doc's or .rtf's?

    Im using vb to code and Ive tried some of the solutions that are offered here but none seem to work.

    It works when im in Crystal Reports itself, but when I run the report from within vs2005 it only gives me limited options.

    Is there any way to do this?

     

    Thank you
      James

    Friday, July 13, 2007 5:58 PM

Answers

  • I have figured it out and have it now exporting to text

    Found on page http://p2p.wrox.com/topic.asp?TOPIC_ID=42089

    This is how:

     

    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

     

    Hope it helps other people with this problem

    Friday, July 13, 2007 7:27 PM

All replies

  • I have figured it out and have it now exporting to text

    Found on page http://p2p.wrox.com/topic.asp?TOPIC_ID=42089

    This is how:

     

    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

     

    Hope it helps other people with this problem

    Friday, July 13, 2007 7:27 PM
  • I have a problem with this code now...

    The Characters per Inch and Lines per Page do not work...

    The options set in them, 16 and 50 do nothing and it defaults the the Crystal Reports default of 12 Characters per inch and an unknown amout of lines per page.

    Does anyone know how to work this problem out or some sort of work around as this is cutting off some text in the fields with the 12 Character per inch.

     

    Thank you

    James

    Wednesday, July 18, 2007 4:59 PM
  • to specify export options you need to have code similar to this:

    crDiskFileDestinationOptions = new DiskFileDestinationOptions();
       crDiskFileDestinationOptions.DiskFileName = exportFilePath;

       //'Set the exporting information
       crExportOptions = crReportDocument.ExportOptions;
       crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
       crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
       crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
       
       //Export the report
       crReportDocument.Export();

    Thursday, July 19, 2007 11:44 PM
  • Hi ralphred.........

     I am new joining of this group............

    I need your help.........

    CrystalDecisions.Shared.ExportOptions.CreateTextFormatOptions

    This is not a member of  CrystalDecisions.Shared.

    So how can I use.......................

     

    Thursday, April 8, 2010 10:01 AM
  • Could you please provide above example in c sharp!

    many thanks

    vijay shiyani

    Sunday, April 10, 2011 7:02 AM
  • I set all this crap up and i still get a page break! why is there no help?

     

    Saturday, May 14, 2011 5:17 AM