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("Cryst
alRuntime.
Applicatio
n.9")
End If
' CREATE THE REPORT OBJECT
'
'The Report object is created by calling the Application object's OpenReport method.
Path = Request.ServerVariables("P
ATH_TRANSL
ATED")
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").MorePrintE
ngineError
Messages = False
session("oRpt").EnablePara
meterPromp
ting = False
session("oRpt").DiscardSav
edData
%>
<%
'=========================
==========
==========
==========
==========
=
' EXPORTING A REPORT
'=========================
==========
==========
==========
==========
=
Set CrystalExportOptions = Session("oRpt").ExportOpti
ons
'This line of code set a variable to reference the ExportOptions Object.
'The variables below (ExportFileName, ExportDirectory, ReportCacheVirtualDirector
y,
'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
:\ReprotsP
rod\Simple
ReportExpo
rt\")
'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.DiskF
ileName = ExportDirectory & ExportFileName
'This line of code specifies the physical location and file name to give
'the export result.
CrystalExportOptions.Forma
tType = CInt(ExportType)
'This line of code specifies the export format (in this case MS Word).
CrystalExportOptions.Desti
nationType
= 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