FlexiTable™
FlexiTable™ maintains a grid of rows and columns of data. A cell is the data at a given combination of row and column. Depending on the data source you have chosen, additional information may be available about data types and formatting.
When you create a report, FlexiTable attempts to format the data in each cell as best it can given the information available. For example, you may want positive numbers formatted in a particular way, and negative numbers in another way.
Each data source describes, to a greater or lesser extent, the type of data it provides. Some, such as CSV, provide little or nothing; others, such as XML,
provide rich descriptions of data types, formatting, and physical positioning.
In this chapter we deal with data types, reports and cell formatting. It's divided into the following sections …
By a data type we mean that, given this information, we can intuitively derive rules about how to present those data.
Whole numbers, floating-point numbers, dates and currency each has implicit rules about the best way to format the
number to indicate some assumed use. Let's take 20060314 as an example. Is this a number, weight, date, or currency?
If it's a number, I want to display it as 20,060,314; if it's a date, I want to see 14-March-2006
(you might want to see something different, but let's not overcomplicate things for now); finally, as a currency we in the UK want to
£2,006.03 (because the currency data type has an implicit four decimal digits),
but in the USA you would expect to see that value rendered as $2,006.03.
Different data sources have differing meta-data that supplement the real data. CSV provides little;
XML provides plenty; others fall in between.
For example, a tag set data source provides data type information, but no formatting information. A tag may be one of three types …
The significance of the data type is that FlexiTable may be able to apply formatting relevant to the data. For example, suppose a number has the value 1000000 (one million). The human eye finds it difficult to see how many digits are in a large number, so in some parts of the world we would write such a number like this: 1,000,000. That is, a comma is placed every three digits. FlexiTable is able to apply similar formatting to integer and whole numbers; in fact, the formatting is similar to that used in Excel™ and other Microsoft Office™ products.
| Data Source | Data Types | Meta Data | Formatting |
|---|---|---|---|
| CSV | Text | None | None |
| XML | Text, Integer, Real, Date, Time, Currency | data type, column width attributes | Picture Strings |
| MicroStation Tags | Text, Integer, Real | data type attribute | None |
| Excel Workbook | Text, Integer, Real, Date, Time, Currency | data type attribute | Picture Strings |
| Relational Database | Text, Integer, Real, Date, Time, Currency | data type attribute | None |
A word or two about data type attributes in XML files may help. An XML file is data-rich,
and FlexiTable uses a schema that take advantage of that richness.
FlexiTable allows each table cell to carry meta-data about the data type and other hints, such as a proposed column width.
Those meta-data are conveyed as attributes to the cell element.
FlexiTable lets you specificy a format picture for positive and negative whole numbers (integers), positive and negative real numbers, dates, and currency. If you're familiar with Microsoft Excel™, you will find FlexiTable's formatting almost identical.
A format picture is a symbolic representation of how you want a number, date, or currency amount to be formatted.
Office applications, such as Excel, use a format picture to specify how a number, date, or currency value should be rendered.
For example, if we format the integer value one thousand (1000) using a picture #,##0, the result is 1,000.
The value minus ten thousand (-10000) might be rendered using (#,##0) to produce (10,000) (if you're an accountant),
or -10,000 (if you're sensible) using the previous picture.
Here are some examples of picture formats and the appearance of the resulting text …
| Data Value | Picture | Formatted Result |
|---|---|---|
| Integer Values | ||
| 1000 | #,##0 | 1,000 |
| -1000 | #,##0 | -1,000 |
| -1000 | (#,##0) | (1,000) |
| -1000 | (#,##0) | (1,000) |
| Real Values | ||
| 1000.0 | #,##0.00 | 1,000.00 |
| 1000.009 | #,##0.000 | 1,000.009 |
| 1000.009 | #,##0.00 | 1,000.01 |
| Date Values (UK locale) | ||
| 15/03/06 | dd MMM yyyy | 15 Mar 2006 |
| 15/03/06 | dd-MM-yy | 15-03-06 |
| 15/03/06 | MM/dd/yy | 03/15/06 |
Create a report starting from the File|Save As… menu in the data editor dialog.
You can save a file in CSV, XML, or HTML format …
It doesn't matter what data source you used to create the table: you can nonetheless save in other formats. The File menu also lets you update a tag set or an Excel workbook, but that doesn't count as report generation.
When you save a report as a CSV file the result is trivial …
"Column 1","Column 2","Column 3","Column 4" "cell 1,1",1234,"cell 1, 3","cell 1, 4" "cell 2,1",2345,"cell 2, 3","cell 2, 4","cell 2, 5" "cell 3,1",3456,"cell 3, 3","cell 3, 4" "cell 4,1",4567,"cell 4, 3","cell 4, 4"
In a CSV file, text is quoted and numbers are unquoted (although you may sometimes receive a CSV file
with quoted numbers (e.g. "1234.56"), which FlexiTable is perfectly happy to read). The file may have captions in the first row.
There is more information about the settings file.
When you save a report as an XML file the result can be rich. In the following abbreviate example, you
can see that there are separate sections for the header, table and footer components …
<?xml version="1.0" encoding="ISO-8859-1"?> <flexitable><!-- FlexiTable copyright © LA Solutions Ltd 2006 --><!-- Created on 09-Mar-2006 --><cell-name>FlexiTable</cell-name> <header-content> <content type="caption"> <string align="right" valign="bottom" text-style="FlexiTable Header">CSV Data Source</string> <caption>Content</caption> </content> <content type="date-stamp"> <string align="left" valign="top" text-style="FlexiTable Date">d-MMMM-yyyy</string> <caption>Date</caption> </content> </header-content> <table> <caption>CSV Data Source</caption> <tr> <th column-width="50">Column 1</th> <th column-width="50">Column 2</th> <th column-width="50">Column 3</th> <th column-width="50">Column 4</th> <th column-width="50">Column 5</th> </tr>... lines omitted ...<tr id="5"> <td type="stringType">cell 4,1</td> <td type="stringType">cell 4,2</td> <td type="stringType">cell 4, 3</td> <td type="stringType">cell 4, 4</td> </tr> </table> <footer-content> <content type="caption"> <string align="left" valign="top" text-style="FlexiTable Footer">FlexiTable by LA Solutions</string> <caption>Content</caption> </content> <content type="date-stamp"> <string align="right" valign="bottom" text-style="FlexiTable Date">dd/MMM/yy</string> <caption>Printed On</caption> </content> </footer-content> </flexitable>
When you save a report as an HTML file the result is visually rich. An HTML file is
created by applying a transformation to an XML file, which converts the XML syntax to
HTML syntax. At the same time, we add a reference to a cascading style sheet (CSS) file,
which specifies the appearance of the resulting web page.
An HTML report combines the rich data content of XML with an appealing visual appearance.
This example was generated from a MicroStation tag set;
it might not be especially attractive, but you can change its appearance to suit your standards by using a different
cascading style sheet.
FlexiTable transforms an XML file to HTML by using the rules in an XSLT transform style sheet.
At the same time it adds a reference to a cascading style sheet (CSS).
Your web browser uses the CSS to render the HTML into an elegant presentation.
Thus, the XSLT determines the content of your web report and the CSS determines the
appearance of your web report.
We've neatly separated the creation of style and content: you can change either or both of the XSLT and CSS
to match your organisation's requirements.
XSLT specifies which data from XML should appear in the HTML page. You can modify the
XSLT to meet your company standards.
There are plenty of books and web sites that deal with the technicalities of XSLT.
An XSLT file, HTML.xsl, is delivered to the FlexiTable project \Templates folder.
XSLT is plain text, so you can edit it using your
favourite text editor, or with something more appropriate such as XML Spy.
Cascading Style Sheets (CSS) have been part of the toolkit of HTML web-page authors for many years.
A CSS file is plain text. It includes directives to the web browser about styles, colours, and text fonts.
There are plenty of books and web sites that deal with the technicalities of CSS.
A sample CSS file, FlexiTable.css, is delivered to the FlexiTable project \Reports folder.