Cyrstal Reports Commandline Exporter - List of Arguments

Crystal Reports Commandline Exporter

List of Arguments

Type crexport -? and you will be able to find out what other arguments that we can possibly use it in Crystal Reports Exporter.

crexport -?
  • -F Crystal Reports filename (i.e. "C:\Report Source\Report1.rpt")
  • -O Crystal Reports Output filename (i.e. "C:\Reports Output\Report1.pdf" )
  • -E Specific the intended export file format.(i.e. pdf, doc, xls .. and etc). If you wish to print Crystal Reports to a printer, simply "-E print" instead of specifying file format.
  • -N Printer Name. If printer name is not specified, it looks for default printer in the computer. If network printer, -N \\computer01\printer1
  • -C Number of copy to be printed (any integer value i.e. 1,2,3..)
  • -S Server Name. Specify a Server Name if you wish crexport to retrieve data from default Data source that is saved in Crystal Reports.
  • -D Database Name. Specify a Database Name if you wish crexport to retrieve data from default Data source that is saved in Crystal Reports.
  • -U Data source/ server login username. Do not specify username and password for Integrated Security connection.
  • -P Data source/ server login password. Do not specify username and password for Integrated Security connection.
  • -a Pass Crystal Reports file parameter set on run time
  • -l Create a log file into crexport.exe directory

-F, Crystal Reports source file

This is the only mandatory (must specify) argument, it allows your to specify the Crystal Reports filename to be exported.

-O, Crystal Reports output file

If -O is not specified, Crystal Reports Exporter will just export the Crystal Reports into the same directory when Crystal Reports source file is resided.

The filename of the exported file is the same as Crystal Report source file and ending with timestamp (yyyyMMddHHmmss).

-E, Crystal Reports Export File Type

There are 13 file formats that you can export a Crystal Reports file.

Use -E to specify desired file format. If -E argument is not supplied, crexport will look into the output file extension, if output file is report1.pdf, it will then set to be Adobe PDF format. If file extension cannot be mapped into supported file format, crexport will export your Crystal Reports into plain text file.

File type Descriptions
txt Plain text file
pdf Adobe Portable Document format (pdf)
doc Microsoft Word
xls Microsoft Excel
xlsdata Microsoft Excel with Data Only
rtf Rich Text format
ertf Editable Rich Text format
tab Tab delimited text file
csv Comma delimited text file
csv Comma delimited text file
xml xml file
htm HTML file
rpt Crystal Reports file
print Print Crystal Report to a printer

-S, Server name or Data Source name

Most of the time, you need not specify the server name or data source name of your Crystal Reports file as every Crystal Reports file saves data source information during design time.

Therefore, you only specify a server name when you want Crystal Reports to retrieve data from another data source that is different from what it is saved in Crystal Reports file during design time.

If your crystal Reports data source is one of the ODBC DSN (regardless of User DSN or System DSN), the DSN will be your Server Name (-S).

-D, Database name

Similarly to Server Name. Database Name is completely optional. You only specify a Database Name when you intend to retrieve data from another database that is different from default database name that is saved in Crystal Reports file.

-U and - P, Username and Password to login to Data source

If you are using database like Microsoft SQL server, MySQL or Oracle, you are most likely required to supply a username and password to login to database.

If you are using trusted connection to your SQL server, you wouldn't need to supply username and password when you run crexport.

If you are using a password protected Microsoft Access database, you need only to specify password and not username.

-a, Pass parameter value to Crystal Reports Exporter

We can have as many Parameters as we want in one Crystal Reports file. When we refresh a Crystal Reports file, it prompts user to input the value of parameter in runtime in order to produce the result that user wants.

You can pass parameter value to crexport.exe when it is executed.

Example 1

Let's take an example of a Crystal Reports file test.rpt located in C: root directory. The Crystal Reports file has two parameters, namely Supplier and Date Range.

c:\>crexport -U user1 -P mypass -S server1 -D Demo
-F c:\test.rpt -O d:\test.pdf -E pdf -a "Supplier:Active Outdoors"
-a "Date Range:(12-01-2001,12-04-2002)"

Rule to pass parameters

  • Use double quote (") to enclose the parameter string (parameter name and parameter value)
  • A colon (:) must be placed between parameter name and parameter value.
  • Use comma (,) to separate start value and end value of a Range parameter.
  • Use pipe (|) to pass multiple values into the same parameter.
  • Parameter name is case sensitive

Example 2

The following crystal Reports "testTraining.rpt" has 5 discrete parameters and 2 range parameters.
Discrete parameters are:

  1. company
  2. customer
  3. branch

Range parameters are:

  1. Daterange
  2. Product

Example of Single value parameters :

c:\>crexport -U user1 -P secret -F C:\Creport\Statement.rpt
-O D:\Output\Statement.pdf -E pdf -S"AnySystem DB"
-a "company:The One Computer,Inc" -a "customer:"MyBooks Store"
-a "branch:Malaysia" -a "daterange:(12-01-2001,12-04-2002)"
-a "product:(AFD001,AFD005)"

Example of Multiple values parameters :

c:\>crexport -F testreport.rpt -O testOutput.xls
-E xlsdata -S order.mdb -a "date:(01-01-2001,28-02-2001)|(02-01-2002,31-10-2002)|(02-08-2002,31-12-2002)"
-a "Client:(Ace Soft Inc,Best Computer Inc)|(Xtreme Bike Inc,Zebra Design Inc)"

Example to print Crystal Reports output to printer

c:\>crexport -F report101.rpt -E print -N "HP LaserJet 1200" -C 3