Solved

exporting report to pdf file

Posted on 2004-08-13
7
752 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
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 250 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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