?
Solved

exporting report to pdf file

Posted on 2004-08-13
7
Medium Priority
?
753 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 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