Advertisement

02.02.2005 at 03:36PM PST, ID: 21299465
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Exporting Crystal Reports 9 to Doc/PDF/Excel format using ASP code.

Asked by srafi78 in Crystal Reports Software

Tags: , ,

Hi I am using the Sample code available at business objects for displaying crystal reports 9 on the web using RDC and ASP.
I try to run the asp code the following code, but the doc file is not created in the folder where my ASP page resides.
Also, I searched for the file crrdc.hlp for getting the different numbers for ExportType for different formats in which the report can be exported, but did not find it on my development machine. Can any one provide me the ExportType numbers to me.

Thanks!
SR

<%@ LANGUAGE="VBSCRIPT" %>
<%
reportname = "SimpleReportExport.rpt"
%>

<%' CREATE THE APPLICATION OBJECT                                                                    
If Not IsObject (session("oApp")) Then                              
  Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.9")
End If                                                              

' CREATE THE REPORT OBJECT                                    
'                                                                    
'The Report object is created by calling the Application object's OpenReport method.

Path = Request.ServerVariables("PATH_TRANSLATED")                    
While (Right(Path, 1) <> "\" And Len(Path) <> 0)                      
iLen = Len(Path) - 1                                                  
Path = Left(Path, iLen)                                              
Wend                                                                  
                                                                     
'This "While/Wend" loop is used to determine the physical path (eg: C:\) to the
'Crystal Report file by translating the URL virtual path (eg: http://Domain/Dir)                                                                        

'OPEN THE REPORT (but destroy any previous one first)                                                    

If IsObject(session("oRpt")) then
      Set session("oRpt") = nothing
End if

On error resume next

Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.

If Err.Number <> 0 Then
  Response.Write "Error Occurred creating Report Object: " & Err.Description
  Set Session("oRpt") = nothing
  Set Session("oApp") = nothing
  Session.Abandon
  Response.End
End If


session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData

%>

<%
'==================================================================
' EXPORTING A REPORT
'==================================================================

Set CrystalExportOptions = Session("oRpt").ExportOptions
'This line of code set a variable to reference the ExportOptions Object.

'The variables below (ExportFileName, ExportDirectory, ReportCacheVirtualDirectory,
'and ExportType) are used as follows:
'  - ExportFileName is the actual file name that should be created by the export process
'  - ExportDirectory is the physical directory where the ExportFileName will be placed
'  - ExportType is a number that specifies the type of file that the export process should
'    create.  For a list of these numbers, please refer to the Crystal Reports Report Design Component
'    help file (crrdc.hlp) in the "ExportOptions Object for the Object Model" section.  Scroll down to
'    the ExportType property.  To change the type of file that the export process should be creating, change
'    the value in the ExportType variable, and change the last portion of the ExportFileName
'    variable.  The example here exports a .doc file, which is a Word file, which is the
'    ExportType "14".
'
'    Some export types have other properties in the ExportOptions object that require values
'    to be set.  For example exporting to HTML.  This type will require that you will also
'    set the HTMLFileName property.  For detailed information on which properties to set,
'    refer to the "ExportOptions Object" topic in the help file (crrdc.hlp)


ExportFileName = "ExportedReport.doc"

Path = Request.ServerVariables("c:\ReprotsProd\SimpleReportExport\")
'While (Right(Path, 1) <> "\" And Len(Path) <> 0)
'iLen = Len(Path) - 1
'Path = Left(Path, iLen)
'Wend
'The While/Wend loop is used to determine the physical location
'of the SimpleReportExport.asp so that we can save the
'ExportedReport.doc in the same location.

ExportDirectory = Path
ExportType = "14"

CrystalExportOptions.DiskFileName = ExportDirectory & ExportFileName
'This line of code specifies the physical location and file name to give
'the export result.

CrystalExportOptions.FormatType = CInt(ExportType)
'This line of code specifies the export format (in this case MS Word).

CrystalExportOptions.DestinationType = CInt(1)
'This line of code specifies that the export destinatin is to be disk.

Session("oRpt").Export False
'This line of code turns of any prompting when exporting.

Response.Redirect ("ExportedReport.doc")
'This line of code redirects the URL to the newly exported file.
'It is important to remember that the exporting is taking place on the web server
'so we need to redirect the user to the newly exported file or they will never
'have access to that file.
%>

Start Free Trial
[+][-]02.02.2005 at 06:25PM PST, ID: 13210264

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Crystal Reports Software
Tags: crystal, report, export
Sign Up Now!
Solution Provided By: RickJ
Participating Experts: 1
Solution Grade: B
 
 
[+][-]02.03.2005 at 10:24AM PST, ID: 13217388

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.06.2005 at 12:17AM PST, ID: 13237636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.06.2005 at 12:02PM PST, ID: 13239739

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43