Print Page | Close Window

Export crystal report to text format

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3539
Printed Date: 08 May 2024 at 5:52am


Topic: Export crystal report to text format
Posted By: jazzright
Subject: Export crystal report to text format
Date Posted: 26 Jun 2008 at 5:46pm
Hi All,

I want to export the crystal report to text format. I am using Visual Studio 2005 and crystal report which is with it.

Please help me how to go about doing it.



Replies:
Posted By: RHar
Date Posted: 27 Jun 2008 at 1:11am
I use this code to export to pdf. I also use a Save file Dialog to get the path and file name to export too.

Dim rpt As New cRptInspections() "My CrystalReportDocument"
rpt = cRptViewer.ReportSource "My CrystalReportViewer"
rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, SaveFileDialog1.FileName)

try for text

rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Text, SaveFileDialog1.FileName)


Posted By: jazzright
Date Posted: 27 Jun 2008 at 1:16am
Hi,

CrystalDecisions.Shared.ExportFormatType.Text option is not available. Any idea how can i make that option available.

any suggestion on the font coz iam printing to a line printer...font are not very clear.


Posted By: RHar
Date Posted: 27 Jun 2008 at 1:20am
Not sure why it don't show.

try
CrystalDecisions.Shared.ExportFormatType.RichText
CrystalDecisions.Shared.ExportFormatType.WordForWindows


Posted By: Puneri
Date Posted: 01 Jul 2008 at 4:53am
what is cRptInspections() in the first line of sample code?
I do not find any such class... please clarify
Also can we set export destination folder path?
My requiremnt is, when report is generated it should be saved on server in app_data
How to do this?


Posted By: RHar
Date Posted: 01 Jul 2008 at 4:58am
cRptInspection is my Crystal Report Document component.


Posted By: RHar
Date Posted: 01 Jul 2008 at 5:03am
You can specify the path and file name.

ex. rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "\\app_server\Docs\test.pdf")


Posted By: Puneri
Date Posted: 01 Jul 2008 at 11:51pm
I'm not getting how u've defined "report document" component. Following is the code, but I'm getting error in it. Can u help me to correct this code?
I have created one aspx page in which I'm displaying contents of crystal report. Also I've to save this report for future reference.
               
Me.CrEmReport.ParameterFieldInfo.Clear()
Me.CrEmReport.ReportSource =Server.MapPath("EmCallupReport.rpt")
Dim ParamFields As ParameterFields = Me.CrEmReport.ParameterFieldInfo
Dim emTicketId As New ParameterField
emTicketId.Name = "VTICKETID"
Dim emTicketId_Value As New ParameterDiscreteValue
emTicketId_Value.Value = objTicket.ticketId
emTicketId.CurrentValues.Add(emTicketId_Value)
ParamFields.Add(emTicketId)
For Each cnInfo As TableLogOnInfo In Me.CrEmReport.LogOnInfo
cnInfo.ConnectionInfo = ConnInfo

Next
    Dim strDate As String = Convert.ToString(objTicket.emRaisedDate)
    Dim objReportDoc As New ReportDocument
    objReportDoc = CrEmReport.ReportSource
    objReportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "\\app_data\\uploads\\Reports\\Emergency\\Emergency_" & objTicket.deptName & "_" & strDate)



Posted By: Puneri
Date Posted: 03 Jul 2008 at 4:42am
I'm getting error at red line as,
Unable to cast object of type 'CrystalDecisions.ReportSource.NonHTTPCachedReportSource' to type 'CrystalDecisions.CrystalReports.Engine.ReportDocument'
Can u please give sample code to create report document component?


Posted By: jhodz2001
Date Posted: 22 Jul 2008 at 12:18am
hello,
 
<Dim strDate As String = Convert.ToString(objTicket.emRaisedDate)
<Dim objReportDoc As New ReportDocument

<objReportDoc = CrEmReport.ReportSource
<objReportDoc.ExportToDisk(ExportFormatType.PortableDocFormat,
 
change these lines to these...
 
Dim strDate As String = Convert.ToString(objTicket.emRaisedDate)
Dim objReportDoc As New ReportDocument
objReportDoc = CrEmReport
objReportDoc.ExportToDisk(ExportFormatType.PortableDocFormat,
 
 
hope it would work for you....
 
 



Print Page | Close Window