Sample: Specifying report output
Report output is specified in the ShellAPI
function as part of the Report
Engine.
Use parameters (p1 - p6) to specify:
- (p1) the name of the XML file for the data. The default path to this file is the FsWebReports\SessionXML directory but you can enter a full path to another directory on this or a different web server.
- (p2) the symbol for the report (e.g., Formula)
- (p3) the output format such as PDF, HTML, MSWORD, or EXCEL
-
(p4) the path and name of the Crystal Report template (e.g. Formula_Report.rpt from the FsWebReports\Source directory)
-
(p5) path for output and custom name of the output (e.g. C:\temp\MyReport.pdf). In addition, a report with a random file name is created in the \FsWebReports\tmp folder. This randomly named report is the one displayed in the web browser.
-
(p6=TRACE argument) provides debug trace capability. In this example, a log file is generated in the http://localhost/FsWebReports/tmp folder. This log file records the program execution path and any errors it encounters.
http://localhost/FsWebReports/launch.aspx? p1=BoatInfo.xml&p2=BOATS&p3=PDF&p4=C:\Optiva\FsWebReports\Source\BoatInfo2008.rpt&p6=TRACE
This example creates Web Report output by using parameters p1 - p5. This example uses the xml file FSWB_Formula.xml for the FORMULA symbol in the default SessionXML directory for PDF output.
The example uses Crystal Reports Template Formula_Report.rpt, creates a copy of the report in C:\Temp and names the report MyReport.pdf.
Workflow.ShellAPI("http://localhost/FsWebReports/Launch.aspx?
p1=FSWB_Formula.xml&p2=FORMULA&p3=pdf&p4=" & sFilePath &
"Source\Formula_Report.rpt&p5=c:\temp\MyReport.pdf")
Advanced example: Using .NET String.Format Method
The File Location object is available so the URL can contain more information and some VB.Net commands can be used to make the script more readable.In this example, the File Location for the URL has placeholders for the all of the options that you put into the URL normally.
In the File Location form, specify this URL:
http://localhost/FsWebReports/
launch.aspx:8080?p1={0}&p2={1}&p3={2}&p4={3}&p5={4}
The
placeholders are the {#} tokens in the string above (0,1,2,3,4). Use these placeholders with
the .Net String.Format
method in the
script.
Dim urlTemplate As String = FileLocation("WEB REPORTS", "URL")
Dim url As String = String.Format(urlTemplate, xmlFileName, "FORMULA",
"PDF", rptFileName, "C:\TEMP\MyReport.pdf")
The highlighted arguments above are used to fill in the placeholders in the URL. This syntax is more readable than the traditional techniques used to build the URL string via concatenation.
The traditional technique, shown here, is more prone to typographical errors.
http://localhost/FsWebReports/Launch.aspx:8080?p1= & xmlFileName & "&p2="
& rptSymbol & "&p3=" & rptOutputFormat & "&p4=" & sFilePath &
"Source\Formula_Report.rpt&p5=" & rptSaveLocation
For
more information about String.Format, see the msdn library: http://msdn.microsoft.com