Chapter 3 Quick Start

Learning how to use WDReportGen

You can teach yourself how to use WDReportGen by choosing from the methods available in this section:

Sample Database

WDReportGen comes with Sample.mdb, a sample database you can use when learning the program. Sample.mdb is a Microsoft Access database. Virtually all of the examples in this manual are based on Sample.mdb data.

The sample reports access the sample database through the ODBC data source name "Report Sample". When you install WDReportGen, you can choose to add the ODBC data source name. And you also can add the ODBC data source name manually.

To create the System DSN "Report Sample", do as follows:

1. Click the Windows Start button, choose Settings, and then click Control Panel.

2. Double-click Administrative Tools, and then double-click Data Sources (ODBC). The ODBC Data Source Administrator dialog box appears.

3. Select the System DSN tab, and then press Add button.

4. Choose Microsoft Access Driver (*.mdb), then press Finish button.

5. In the ODBC Microsoft Access Setup dialog box, type Report Sample in the Data Source Name box.

6. Press the Select button, and browse to select Sample.mdb.

7. Press OK button to close the ODBC Microsoft Access Setup dialog box.

8. Press OK button to close the ODBC Data Source Administrator dialog box.

Steps of Reporting

To create a report with WDReportGen, you should do as follows:

1. Prepare works

Before you create a report, you should determine the layout of the report, and know where and how to get the data.

You must know how to access the databases you are reporting from. So you need the data source name, user name and password. If you don't have data sources added, please add data sources first. Run ODBC Administrator, you can add a new data source. For detailed information about configuring ODBC, refer to ODBC Administrator Help.

2. Make a report template file

Create a report template file using Microsoft Word. For detailed information about report template, refer to "Report Templates" in this document.

3. Create a WRF file

Create a WRF file with a .wrf extension using WDReportGen. There are tow steps to create a WRF file.

(1) Configure the report

Define the names of data sources, the name of the report template file, the name of report file and the name of log file. If you want to use parameters in SQL statements, define these parameters.

(2) Write functions

Write functions and SQL statements that specify how to get data from data sources and how to put data into the report.

For detailed information, refer to "Reporting with WDReportGen" in this document. Define the names of data sources, the name of report template file, the name of report file and the name of log file. If you want to use parameters in SQL statements, define these parameters.

(2) Write functions

Write the functions and SQL statements that specify how to get data from data sources and how to put data into the report.

4. Run the WRF file

Run the WRF file to generate a report in Microsoft Word document. For detailed information about running report, refer to "Running a WRF File" in this document.

My First Report

The following tutorial has been designed to guide you to create your first report. In this tutorial, you will get an introduction to the program as you create a Customer List report. The Customer List is one of the most basic business reports and typically has information such as Customer Name, City, Country, and Contact Name.

Creating a report template

1. Run Microsoft Word, a new document will open.

2. On the Table menu, point to Insert, and then click Table. Under Table size, select the number of columns and rows. Press OK button.

3. Click the cell A1, type "Customer Name". In the same way, you input "City", "Country" and "Contact Name" into the cells B1, C1 and D1.

4. Format the text of A1, B1, C1 and D1 as you like, including font, font size, font colour, bold, background, alignment and border.

5. You can change the width of these columns. The report template you have made is as follows:

Word Report Template - Customer List

6. Click Save on the File menu, chose a directory such as "C:\Report", type custlist.docx in the File name box and press Save button.

7. Click Close on the File menu.

Creating a WRF file

1. Run WDReportGen.

2. Click New on the File menu.

3. Click Save on the File menu, chose the directory to which you have saved the report template, type custlist.wrf in the File name box and press Save button.

Configuring the report

1. On the Report menu, click Configuration. The Configuration dialog box appears.

2. Click the File tab.

In the Template File box, type custlist.docx; In the Report File box, type Report\custlist.docx; In the Log File box, type Log\custlist.log.

3. Click the Data Source tab.

Press New button, the New Data Source dialog box appears. In the Name box, type Report Sample, press OK button.

4. On the Configuration dialog box, press OK button.

Inputting a function

In the editor windows, input a function as follows:

You can test the SQL statement in a query tool such as Microsoft Access or Microsoft Query.

@F1=Report(table=1 cell=A2)
SELECT CompanyName
,CityName
,CountryName
,ContactName
FROM Customers, Cities, Countries
WHERE Customers.CityCode = Cities.CityCode
AND Customers.CountryCode = Cities.CountryCode
AND Customers.CountryCode = Countries.CountryCode
ORDER BY CompanyName,CityName,CountryName
;

You can test the SQL statement in a query tool such as Microsoft Access or Microsoft Query.

Understanding the function

Before going any further, let us understand this function.

1. The Report function will execute the SQL statement, get data from data source, and put data into the report.

2. The table argument identifies a table, and the value 1 is the index number of the table. So it is the first table.

3. The cell argument specifies the cells that the first record will be filled into. The value is A2. So WDReportGen will fetch the first record, put the value of CompanyName field into A2, the value of CityName field into B2, the value of CountryName field into C2, and the value of ContactName field into D2. An then it will fetch the next record, put them into A3,B3,C3 and D3......

Running a WRF file

1. On the Report menu, click Run, the Run Report dialog box appears.

2. Press Start button to run the WRF file.

3. WDReportGen will generate a report.

4. After the status is Done, click Close button.

Opening a report

1. On the File menu, click Open Report File to open the report you have generated.

You can view and check the report.

2. On the File menu, click Open Log File to open the log file that recorded the log information in the report generating. You can check the log.

3. Close the report file and the log file.

Modifying the report template

1. On the File menu, click Open Template File to open the report template.

2. Change the width of columns. It is very useful to copy some sample data from the report file into the report template for formatting.

3. Insert text before the table, and type Customer List as the report title. To insert text before a table, click in the upper-left cell in the first row of the table, place the insertion point before the text, and then press ENTER.

4. Select the second row, and insert a row to the table.

5. Add a border to the table. Select the table, click Borders and Shading on the Format menu, and then click the Borders tab. Select the options you want, and press OK button. The external border can be different from the internal border. The report template you have made is as follows:

Word Report Template - Customer List2

6. Select the first row of the table, and click Heading Rows Repeat on the Table menu.

7. Save and close the template file.

Modifying the function

In the editor windows, modify the function as follows:

@F1=Report(table=1 cell=A2 rangecount=2)
SELECT CompanyName
,CityName
,CountryName
,ContactName
FROM Customers, Cities, Countries
WHERE Customers.CityCode = Cities.CityCode
AND Customers.CountryCode = Cities.CountryCode
AND Customers.CountryCode = Countries.CountryCode
ORDER BY CompanyName,CityName,CountryName
;

The rangecount argument specifies the number of ranges in the report template. You have defined two blank ranges in the report template. One row is one range. If you hope that the format of the last row/column border is different from the others, you can define two ranges in the report template.

Generating the report again

1. Save the WRF file.

2. Run the WRF file to generate the report.

3. Open the report, view and check the report.

The report should now look similar to the following:

Word Report Sample - Customer List

Now you have created a report.

Samples

After WDReportGen is installed, some sample reports are installed too. Use these reports to learn WDReportGen. The sample reports can be changed to adapt to your own needs.

The sample reports include a sample database, some report template files (.docx) and WRF files (.wrf). They are located in the Application Data\LJZsoft under All Users or your profile folder.

Directory Description
{commonappdata}\LJZsoft\Common\SampleDatabase Contains the sample database "Sample.mdb".
{commonappdata}\LJZsoft\WDReportGen\Samples Contains the report template files (.docx) and the WRF files (.wrf).
{commonappdata}\LJZsoft\WDReportGen\Samples\Report Contains the report files (.docx) generated by WDReportGen.
{commonappdata}\LJZsoft\WDReportGen\Samples\Log Contains the log files created by WDReportGen during generating report files.

{commonappdata} is the path to the Application Data folder under All Users. The Application Data folder is usually at:

Windows XP: C:\Documents and Settings\All Users\Application Data\

Windows Vista or later: C:\ProgramData\