Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

exporting report to pdf file

Posted on 2004-08-13
7
Medium Priority
?
754 Views
Last Modified: 2012-05-05
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.ExportOptions
        Dim mydiskfile As CrystalDecisions.Shared.DiskFileDestinationOptions
        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.DiskFileDestinationOptions
        mydiskfile.DiskFileName = myexportfile
        myexportoptions = myReport.exportoptions
        With myexportoptions
            .DestinationOptions = mydiskfile
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With
        myReport.export()
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"
        Response.WriteFile(myexportfile)
        Response.Flush()
        Response.Close()
        System.IO.File.Delete(myexportfile)

    End Sub
0
Comment
Question by:tentavarious
  • 4
  • 2
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 11793468
0
 
LVL 42

Expert Comment

by:frodoman
ID: 11795184
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
0
 

Author Comment

by:tentavarious
ID: 11795398
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.CrystalReports.Engine.LoadSaveReportException: Invalid file name.

Source Error:


Line 60:             .ExportFormatType = .ExportFormatType.PortableDocFormat
Line 61:         End With
Line 62:         myReport.Export()    'my code stops here
Line 63:         Response.ClearContent()
Line 64:         Response.ClearHeaders()
 
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 101

Expert Comment

by:mlmcc
ID: 11795565
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
0
 

Author Comment

by:tentavarious
ID: 11796001
I get the same error either way.  If i take the space out or put a slash in, same error occurs
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 11796294
I assume you have write permissions to the directory being used.

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 11798223
Glad I could help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question