Command line client

The NCReport engine is also available as a command line client executable. It can run a report definition file to a printer, to the preview window, or to a file output without writing any code, which makes it useful for testing reports and for running reports from scripts.

Running the command line executable

To run the command line engine, use the NCReport executable in the bin directory of the installation:

NCReport [options]

If the executable is started without any options, it prints the list of available options and exits.

Example: running a report definition file to a PDF file with a parameter:

NCReport -f ../reports/gettingstarted_demo.xml -o pdf -of result.pdf -par firstname,Robert

Command line options

-?, --help

Displays the help text and exits.

-v, --version

Displays the NCReport version and exits.

-f, --report-file <filename>

Name of the report definition (XML) file to run.

-q, --sql-driver <driver>

Qt SQL driver name for the database connection, for example QDB2, QIBASE, QMYSQL, QOCI, QODBC, QPSQL, QSQLITE, or QTDS. The default is QMYSQL.

-h, --host <hostname>

Database host name or IP address. The default is localhost.

-u, --user <username>

Database user login name.

-p, --password <password>

Database user login password.

-d, --database <dbname>

Name of the database to use. A database connection is opened only if this option is specified.

-pt, --port <port>

Database port number. If not specified, the default port of the driver is used.

-c, --connection-id <id>

SQL connection name (ID). It must match the connection ID of the SQL data sources in the report. The default is conn. If the ID is default, the connection is added as the default database connection.

-cs, --connect-string <string>

Joined connection string in <user>/<password>@<host> format. It sets the user name, password, and host name in one step.

-co, --connect-option <opt>

Connection option string.

-o, --output <output type>

The output type: print, preview, pdf, svg, html, excel, or image. Use print to send the report to a printer, or preview to show the report in a preview window. The excel output generates an Excel-compatible HTML file. The default output is preview.

-of, --output-file <filename>

Output file name. Required for the file-based output types (pdf, svg, html, excel, and image). The default is test.pdf.

-n, --printer <printername>

Name of the target printer.

--copies <1..50>

Number of copies when the output is a printer.

--nodialog

Runs the report to the printer without showing the printer dialog.

-dbid, --report-db-id <id>

ID number of the database record that contains the report definition (XML) text. This option and --report-file must not be used together.

-par, -add-parameter <parametername>,<value>

Adds a custom parameter to the report. Specify the name and the value of the parameter separated by a comma, for example firstname,Robert. The parameter can be referenced as $P{parametername} in the report definition. The option can be used more than once to add several parameters.

-l, --language <code>

Two-letter international language code of the current report language. Works only when the specified language is defined in a multilingual report.

-td, --template-dir <dir>

Sets the default template directory used for additional files, such as chart templates.

-hs, --htmlstrategy <1|2>

HTML output generation strategy: 1 = each section is rendered as one table (default); 2 = sections are always rendered as separate tables.

-css, --css-file <filename>

Style sheet file to be generated for the HTML output. If not set, the style sheet is included in the target HTML file.

In the current version of the console application, the --connect-option and --report-db-id options are accepted, but they are not applied when the report runs; the report definition is always loaded from the file specified by --report-file.