tentavarious
asked on
exporting report to pdf file
Hello all,
I am using visual studio.net 2003 and the bundled version of crystal reports. I have created a web form that holds a report. I would like for the user to click a button and export the report to a pdf. There are errors in my code, visual studio does not like this line of code: Dim myReport as New web_printing_report, any ideas?
Private Sub btnpdf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnpdf.Click
Dim myexportoptions As CrystalDecisions.Shared.Ex portOption s
Dim mydiskfile As CrystalDecisions.Shared.Di skFileDest inationOpt ions
Dim myexportfile As String
Dim myReport As New web_printing_report ' this line of code is not excepted
myexportfile = c:\timecardreport\pdf " & _
session.sessionid.tostring & ".pdf"
mydiskfile = New CrystalDecisions.shared.Di skFileDest inationOpt ions
mydiskfile.DiskFileName = myexportfile
myexportoptions = myReport.exportoptions
With myexportoptions
.DestinationOptions = mydiskfile
.ExportDestinationType = .ExportDestinationType.Dis kFile
.ExportFormatType = .ExportFormatType.Portable DocFormat
End With
myReport.export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(myexpor tfile)
Response.Flush()
Response.Close()
System.IO.File.Delete(myex portfile)
End Sub
I am using visual studio.net 2003 and the bundled version of crystal reports. I have created a web form that holds a report. I would like for the user to click a button and export the report to a pdf. There are errors in my code, visual studio does not like this line of code: Dim myReport as New web_printing_report, any ideas?
Private Sub btnpdf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnpdf.Click
Dim myexportoptions As CrystalDecisions.Shared.Ex
Dim mydiskfile As CrystalDecisions.Shared.Di
Dim myexportfile As String
Dim myReport As New web_printing_report ' this line of code is not excepted
myexportfile = c:\timecardreport\pdf " & _
session.sessionid.tostring
mydiskfile = New CrystalDecisions.shared.Di
mydiskfile.DiskFileName = myexportfile
myexportoptions = myReport.exportoptions
With myexportoptions
.DestinationOptions = mydiskfile
.ExportDestinationType = .ExportDestinationType.Dis
.ExportFormatType = .ExportFormatType.Portable
End With
myReport.export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(myexpor
Response.Flush()
Response.Close()
System.IO.File.Delete(myex
End Sub
For this line of code to work:
Dim myReport as New web_printing_report
You need to add your report to your project ( I assume web_printing_report is the name of your report?). In your solution explorer, rt-click on your project and select Insert Existing Item then browse to your report. This will create a class for your report and you may then use "New reportname" to instantiate the report.
HTH
frodoman
Dim myReport as New web_printing_report
You need to add your report to your project ( I assume web_printing_report is the name of your report?). In your solution explorer, rt-click on your project and select Insert Existing Item then browse to your report. This will create a class for your report and you may then use "New reportname" to instantiate the report.
HTH
frodoman
ASKER
Ok now i am getting this error
Server Error in '/tool/Tool128' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Invalid file name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalRe ports.Engi ne.LoadSav eReportExc eption: Invalid file name.
Source Error:
Line 60: .ExportFormatType = .ExportFormatType.Portable DocFormat
Line 61: End With
Line 62: myReport.Export() 'my code stops here
Line 63: Response.ClearContent()
Line 64: Response.ClearHeaders()
Server Error in '/tool/Tool128' Application.
--------------------------
Invalid file name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalRe
Source Error:
Line 60: .ExportFormatType = .ExportFormatType.Portable
Line 61: End With
Line 62: myReport.Export() 'my code stops here
Line 63: Response.ClearContent()
Line 64: Response.ClearHeaders()
There is a space in the file name between \pdf and the sessionid
myexportfile = c:\timecardreport\pdf " & _
session.sessionid.tostring & ".pdf"
Did you mean to have a \ there or have the files named pdfSESSIONID.pdf
mlmcc
myexportfile = c:\timecardreport\pdf " & _
session.sessionid.tostring
Did you mean to have a \ there or have the files named pdfSESSIONID.pdf
mlmcc
ASKER
I get the same error either way. If i take the space out or put a slash in, same error occurs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help
mlmcc
mlmcc
Do you have CRAXDRT included as a reference?
Look at
http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_web_samples.exe.asp
http://support.businessobjects.com/communityCS/FilesAndUpdates/walkthrough_supportfiles.zip.asp
http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_win_samples.exe.asp
http://support.businessobjects.com/communityCS/FilesAndUpdates/rtm_web_forms_sample.zip.asp
mlmcc