:doctype:book = Smart Formatting
Drillbridge reports have a Smart Formatting feature that can be turned on and off. If turned off, the data in a Drillbridge table does not receive any formatting beyond having its value pulled from the database (this is the default option).
If Smart Formatting is turned on, Drillbridge will inspect the types of data (the columns) that are returned from the SQL query and attempt to format them to make their presentation nicer. This formatting applies to the following types of columns:
-
Date (DATE)
-
Time (TIME)
-
Timestamp (TIMESTAMP)
-
Integer (BIGINT, INTEGER, SMALLINT)
-
Decimals (DECIMAL, NUMERIC, DOUBLE, FLOAT)
Most notably, Drillbridge will not attempt to do any formatting to text-based columns such as the following:
-
Character (VARCHAR, NVARCHAR, CHAR, NCHAR)
-
Text (TEXT, CLOB)
-
Other types (BLOB, TINYINT, BIT)
Additionally, Drillbridge will take into consideration the locale of the
user and try to format according to that. The locale is determined by
the Accept-Language header submitted by the web browser.
Date Formatting
Dates are formatted using the "SHORT" formatting type in Java, taking the current locale into consideration. For example, in English the date August 5th, 2014 is formatted as 8/5/14. In French this is 05/08/14.
Time Formatting
Standard formatting in English (US) would look like: 3:53 PM. In French this would appear as 15:53.
Timestamp Formatting
Timestamp formatting is a combination of Date and Time formatting (the date format has a space and the formatted time appended to it), such as 05/08/14 15:53.
Integer & Decimal Formatting
The precision and scale attributes of a numerical column will be inspected in order to determine how they should be formatted. Let’s consider a column with a type of DECIMAL(13, 2). In SQL parlance this means that the values can have 13 digits and 2 of those are to the right of the decimal. This can be used to represent typical currency values.
We’ll say that the database value for a particular row is
1234567.1234. With Smart Formatting turned on, with an English web
browser, this will output as:
1,234,567.12
In a French locale, the output is:
1 234 567,12
Note the different grouping (thousands) and decimal separators.
Circumventing Formatting
Drillbridge will not attempt to do any formatting on columns that have a character-based type. If you need to use Smart Formatting but want to exclude a column from getting formatted, then find a way to cast or otherwise convert it to a string. For example, if you have a year value stored in an integer-based column that represents the year and turn Smart Formatting on in the French locale, the output would be:
2 014
Note that a space is the thousands or grouping separator in the French locale. For U.S. English, Smart Formatting would convert the above value to the following:
2,014
Either way, it’s unlikely that this is the desired result. So to use Smart Formatting in the report but not have it apply to this column, we just need to cast it to a character using something like the following:
SELECT TO_CHAR(AMOUNT) FROM DUAL
When Drillbridge interprets the SQL results, AMOUNT will appear as a VARCHAR instead of some integer type, and spaces/commas will not be added even with Smart Formatting turned on.
Other Quirks
Note that using ROUND() to round to a certain number of decimals does
not affect the scale that Drillbridge analyzes from the column. For
example, if you have currency values stored in a column with a
definition of DECIMAL(13, 4) such that there are four places stored
after the decimal but want Drillbridge to just show two, then you would
want to cast the value rather than round it.
SELECT CAST(AMOUNT AS DECIMAL(13, 2)) AS AMOUNT FROM DUAL
:doctype:book = Custom Stylesheet/HTML Tips
Drillbridge allows custom styling in a few different ways. It is possible to specify a global stylesheet that affects all reports, as well as report-specific options including stylesheets, header, and footer.
Global Stylesheet
The global stylesheet server setting will be added to every report that is run from the server. This allows for easily customizing the appearance of every report.
Downloading a Result
Reports on the Lumen theme carry a single Download button, which opens a dialog rather than downloading straight away. The reader chooses an Excel workbook or a delimited text file, whether to include a row of column headers, and for text, the column delimiter and when values should be quoted.
The dialog opens on whatever the report is configured for, so a reader who changes nothing gets the file its author set up. What they change applies to that download only; it does not alter the report or affect anyone else. A report with Hide download buttons set has no button and no dialog, as before.
Quoting
A value holding the delimiter, a quote character or a line break cannot be written plainly: a reader opening the file would see the value split across columns, or the rest of the row land in the wrong place. The When needed setting, which is the default, quotes exactly those values and leaves the rest alone, doubling any quote character inside a value as RFC 4180 requires. Always quotes every value, which some tools expect. Never quotes nothing and so cannot represent those values; it is there for a reader that does not understand quoting at all.
Before this release Drillbridge offered only the equivalent of Always and Never, and did not double a quote inside a value, so a report whose data held quote characters produced a file that parsers read incorrectly. Reports that had Quote fields turned on now behave as Always; those that had it off now quote when needed rather than never, which changes the output only for values that were previously written in a way that could not be read back.
Light and Dark
Reports on the Lumen theme are drawn in light or dark colors. A report opens in whichever the reader’s operating system asks for, and a button in the report header, beside Download, switches between the two. It is the half-filled circle, and hovering it says which way it will switch.
Choosing one is a deliberate choice that then beats the operating system setting: a reader who picks light keeps light even on a machine set to dark. The choice is remembered in the reader’s browser and applies to every report they open afterwards, so it is made once rather than on each drill. Because it lives in the browser, it does not follow a reader to another machine, and Drillbridge neither stores nor reports it.
To return to following the operating system, clear the site data for the Drillbridge server in the browser.
Dark colors are produced by changing the values of the theme’s color variables rather than by overriding each rule, so a Global Stylesheet or report stylesheet that sets its own colors keeps them in both. A stylesheet that assumes a light background should set its own background color alongside any text color it sets, so that it reads in either.
Lumen Classic also follows the operating system, but it has no button and predates this behavior. Prophecy and Sequoia are always light.
CSS "Hooks"
Drillbridge report data tables are generated with specific CSS classes in order to allow the table, rows, and specific columns to be easily formatted.
The single data table for the report data has a CSS class of
drillbridge-table.
Each row in the data table has a class of dr. Odd rows in the table
will additionally have a class of odd. This makes it easy to do custom
styling for alternating rows.
Each column in the data table has a class of dc as well as a class of
dc-X where X is the column index. Note that column indices start at 1.
So in a 10 column table the classes would be dc-1, dc-2, ...,
dc-10.
Header & Footer
Each report can have a custom header and footer. You can include
arbitrary HTML in these blocks. This custom HTML/text will be placed
inside a <div> block at the top and bottom of the page. The header
contents will be inside the following block:
<div class="header">
Your custom HTML
</div>
Similarly, the footer text will be placed in this block near the end of the page:
<div class="footer">
Your custom HTML
</div>
You can use custom image tags and other external items so long as they are hosted somewhere on the network that is accessible via the typical web-browser session (i.e., Drillbridge itself cannot host custom images or files).