t1clausen
asked on
Exporting Crystal 10 directly to excel file
Ok I have this working on one PC in a sub folder. When I move the code to another folder it won't work any more. I've got the files now under my main web folder and the permissions all look right. It runs the script and redirects me, but never creates the xls file. The text file that comes with this example makes reference to ReportCacheVirtualDirector y and resetting it, but they don't have it set in thier example. HELP!!!
Here is the file....
<%@ LANGUAGE="VBSCRIPT" %>
<%
'========================= ========== ========== ========== ========== ======
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO EXPORT A REPORT
'========================= ========== ========== ========== ========== ======
'
' CONCEPT
'
' ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
' - create the application object
' - create the report object
' - open the report
'
' EXPORTING A REPORT
' - set a variable to reference the ExportOptions Object of the report
' - set the ExportOptions for the report including the export destination and export type
' - redirect the user to the newly exported file so they are prompted to download or view
' the file
'
'========================= ========== ========== ========== ========== =
%>
<%
' This line creates a string variable called reportname that we will use to pass
' the Crystal Report filename (.rpt file) to the OpenReport method contained in
' the AlwaysRequiredSteps.asp.
reportname = "reports/SimpleReportExpor t.rpt"
%>
<%
'========================= ========== ========== ========== ========== =
' ALWAYS REQUIRED STEPS - Version for Exporting (does not create report or
' application objects in session)
'
' Include the file AlwaysRequiredStepsExport. asp which contains the code
' for steps:
' - create the application object
' - create the report object
' - open the report
'========================= ========== ========== ========== ========== =
%>
<!-- #include file="AlwaysRequiredStepsE xport.asp" -->
<%
'========================= ========== ========== ========== ========== =
' EXPORTING A REPORT
'========================= ========== ========== ========== ========== =
Set CrystalExportOptions = oRpt.ExportOptions
'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.xls"
Path = Request.ServerVariables("P ATH_TRANSL ATED")
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 = "38"
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.
oRpt.Export False
'This line of code turns of any prompting when exporting.
Response.Redirect ("ExportedReport.xls")
'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.
%>
Here is the file....
<%@ LANGUAGE="VBSCRIPT" %>
<%
'=========================
' WORKING WITH THE REPORT DESIGNER COMPONENT AND ASP TO EXPORT A REPORT
'=========================
'
' CONCEPT
'
' ALWAYS REQUIRED STEPS (contained in AlwaysRequiredSteps.asp)
' - create the application object
' - create the report object
' - open the report
'
' EXPORTING A REPORT
' - set a variable to reference the ExportOptions Object of the report
' - set the ExportOptions for the report including the export destination and export type
' - redirect the user to the newly exported file so they are prompted to download or view
' the file
'
'=========================
%>
<%
' This line creates a string variable called reportname that we will use to pass
' the Crystal Report filename (.rpt file) to the OpenReport method contained in
' the AlwaysRequiredSteps.asp.
reportname = "reports/SimpleReportExpor
%>
<%
'=========================
' ALWAYS REQUIRED STEPS - Version for Exporting (does not create report or
' application objects in session)
'
' Include the file AlwaysRequiredStepsExport.
' for steps:
' - create the application object
' - create the report object
' - open the report
'=========================
%>
<!-- #include file="AlwaysRequiredStepsE
<%
'=========================
' EXPORTING A REPORT
'=========================
Set CrystalExportOptions = oRpt.ExportOptions
'This line of code set a variable to reference the ExportOptions Object.
'The variables below (ExportFileName, ExportDirectory, ReportCacheVirtualDirector
'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.xls"
Path = Request.ServerVariables("P
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 = "38"
CrystalExportOptions.DiskF
'This line of code specifies the physical location and file name to give
'the export result.
CrystalExportOptions.Forma
'This line of code specifies the export format (in this case MS Word).
CrystalExportOptions.Desti
'This line of code specifies that the export destinatin is to be disk.
oRpt.Export False
'This line of code turns of any prompting when exporting.
Response.Redirect ("ExportedReport.xls")
'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.
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://support.businessobjects.com/library/kbase/articles/c2014894.asp
Had to set the write permissions and it created the file but it was a 0 byte file. Clicked the link above and found the way around that. Thanks!
Had to set the write permissions and it created the file but it was a 0 byte file. Clicked the link above and found the way around that. Thanks!
Have you tried replacing the variables (ExportDirectory, ReportCacheVirtualDirector