To run a Crystal Report using a command, ReCrystallize Server may be called from a script, batch file or another application that does not involve a web browser. Reports may be printed, emailed, or saved to disk.
Using Windows PowerShell, the Invoke-WebRequest cmdlet can initiate a request to ReCrystallize Server.
Example: Run a report named chart.rpt on the local server and save it to disk in the Excel Data Only format:
Invoke-WebRequest -Uri "http://localhost/ReCrystallizeServer/ViewReport.aspx?reportName=chart.rpt&exportFmt=ExcelData&saveTo=chart.xls"
Example: On the local server, export a report named chart.rpt and email the report as a PDF:
Invoke-WebRequest -Uri
"http://localhost/ReCrystallizeServer/ViewReport.aspx?reportName=chart.rpt&exportFmt=PDF&mailTo=test@test.com"
Example: On the local server, set the report parameter named dateparm and print to the printer named HP Laserjet:
Invoke-WebRequest -Uri
“http://localhost/ReCrystallizeServer/ViewReport.aspx?reportName=chart.rpt&dateparm=Date(2021,03,15)&serverPrinter=HP Laserjet”
If PowerShell scripts are disabled on the server, they may be enabled by opening PowerShell as Administrator and running
Set-ExecutionPolicy RemoteSigned
Similarly, curl may be used from a command line or batch file.
curl "http://localhost/ReCrystallizeServer/ViewReport.aspx?reportName=chart.rpt&mailTo=test@test.com"
The curl command is included with recent versions of Windows. If the curl command is not a recognized on your server, it may be downloaded from https://curl.se/windows/ where documentation is also available.
An example PowerShell script and an example batch file are available in the “ReCrystallizeServer\Example Scripts” folder.
Post your comment on this topic.