|Exportizer Users' Guide||vlsoftware.net|
Example of Using Template in HTML Export
In this example we will learn how to use HTML template for exporting data (including images), conditionally highlighting the data, and aggregating the data.
Suppose we have a certain table with product list, which is changed from time to time...
First, we need to prepare a template for the target web page. We either use an existing html file for this, or create a new one, making all necessary design.
In the template, we create specific dynamic areas to be filled during the export process.
1. Prepare Title html attribute (<Title> tag). It will be filled from Document title export option. Use vle_expr macro for this:
2. Prepare the topic title. It will be filled from Document title export option. Use vle_expr macro for this:
3. Prepare the table. It will be filled from the source dataset. It is the most complex task.
Below the table header row, put vle_loop_start and vle_loop_end macros. Between them, put html elements and vle_expr macros, which will form one data row in the target table. All these elements will be ouptutted to target document for each source dataset row.
Here, we will add also images from the database in the first column, and will use conditional highlighting the data in the second column by using bold font (<b> tag) for sizes which are larger than 1000 Kb.
4. Add a table footer for totals. It will be filled with aggregated values calculated during the export process.
We should place it above of the table closing tag.
Now, the template is ready. Name it products_template.html, for example.
In browser, the main part of the template will look something like this:
Then, back to the program and prepare export options. Click Export button. The Export dialog will appear. Specify the target file, template file, and document title:
Now, click Export and check the result. In browser, the main part of the target page will look as following:
We can get such a result also by using the command line:
or via the action file with the following content:
|Copyright (C) 2017 Vitaliy Levchenko Software. All rights reserved.|