XLSX conversion

TreeGrid documentation

This document contains information about TreeGrid to XLSX export.

Export to XLSX

Functions to perform actual export / conversion.
new 12.1 global func. blob|string

XlsxExport

(TGrid grid, string restype = blob)
Performs actual conversion of the provided TreeGrid object to XLSX.
The result is xlsx file, depending on the restype parameter in blob form or as a base64 encoded string.
new 12.1 global func. void

XlsxSave

(blob|base64string xlsx, string fname)
Offers saving dialog for the file provided in blob form or as a base64 encoded string.
Works on IE10 and newer, use server-based solution on older browsers.

Export Menu

Rows to export Offers header and footer rows selection - only the checked rows will be exported.
Columns to export Offers columns selection - only the checked columns will be exported. With AutoCols configuration (SpreadSheet scenarios) data columns aren't offered and always exported (up to GetLastDataCol).
Options:  
Export all rows expanded Ignores Expanded and exports whole Row Tree(s) expanded.
Export all rows (unfiltered) Ignores filter settings.
Export tree as Excel outline Convers Row Tree to the Excel outline.
Indent tree in main column Indents child rows of a Row Tree in the main column (according to their depth-level).
Export hidden rows / columns Ignores hidden rows /columns setting.
Export columns in reversed order Exports columns in reversed order (as a part of RTL support)
Freeze head rows Freezes (anchors) header rows.
Freeze left columns Freezes (anchors) left columns.
Export only selected rows Exports only selected rows.
Export only selected columns Exports only selected columns.
Export only selected cells Exports only selected cells (fills the rest with blanks).
No HTML Converts html as literal string if true

Internal Options

Some behavior can be adjusted by providing the opts parameter when instantiating the Converter object or by SetOptions() function.

Some of the options are also set by the Export Menu (if shown) - the menu setting is more important then (it overrides the options) but it's initial value is set by the opts parameter.

valign"top" Default vertical align
fontSize10 Default font size
fontFace"Calibri" Default font face
freezeHeadfalse Freeze head rows
freezeLeftfalse Freeze left columns
onlySelRowsfalse Export only selected rows
onlySelColsfalse Export only selected columns
onlySelCellsfalse Export only selected cells
colorSelRows"#ffff00" Colorize selected rows (turned of if false)
colorSelCols"#ffff00" Colorize selected columns (turned of if false)
colorSelCells"#00ffff" Colorize selected cells (turned of if false)
emptyCellstrue Export empty cells as actual cells with empty string - overflowing text of preceeding cells will be hidden but the resulting Xlsx file of large Grids may be larger
showForcedExportCheckboxtrue Columns with CanExport='2' (export & don't show in the Export Menu) will be shown in the Export Menu with disabled checkbox
defTextShadowColor"#999999" Default TextShadowColor (RGB value)
defTextShadowPattern"lightGray" Default TextShadow emulation fill pattern (lightGray = mid-dense dots)
addTableBordertrue Add border around the table and it's sections (header, footer, left and right columns)
nohtmlfalse Converts html as literal string if true

Supported features

List of supported features. These will be converted as expected or with results functionally similar to the source.

Fixed rows & columns Any number of rows/cols connected to the left panel (with row numbers) resp. to the top bar (with col names) will be fixed in the resulting XLSX also.
XLSX does not support fixing rows/cols in the middle, on the right side or at the bottom and such rows/cols will be converted as normal.
Row height & column width Row height & col width are converted, do not expect exact match though (as sizes in XLSX are not stated in pixels).
Hidden rows & columns Hidden rows/cols will be converted as expected.
Colspan & rowspan Colspan & rowspan will be converted as expected except for spanning through row/col tree.
Row trees Row trees will be converted to row outlines (groups).
Outline extent indicators with collapse/expand buttons will be shown in the left panel, independently on the position (col) of the original tree.
Indentation of MainCol's content in child rows is supported.
ReversedTree is supported.
Expanded is supported.
Multi-row text Endlines in cells of Lines and Html Type will be converted as expected.
Horizontal align Align is converted as expected, except "Scroll" is changed to ordinary "center".
Vertical align VAlign is supported.
Images See HTML tags: <img>
Filters When the filter row is present (and exported) and a filter is active, it is exported as a cell with operator sign in bold red before a filter value.
Attributes
Enlisted attributes will be applied during conversion.

Global attributes
<Cfg>ExportAttrs new Comma separated list of attribute names which will be applied during export (if present where relevant).
<Cfg>ExportFormat A new possible value 3 - XLSX.
<Cfg>ExportType Filtered, Expanded, Hidden, Outline, Indent, Rtl (Strings, Dates are ignored)
With the Hidden flag hidden rows are converted as hidden (otherwise they're just thrown out).
<Cfg>ExportRound
<Cfg>ExportCols Apart from column list the Xlsx export menu dialog contains also selects of Head and Foot rows to export (these with CanExport='1').
<Cfg>NoFormatEscape Applied to Date, Int, Float, Text, Lines and Pass types (as original).
<Cfg>BaseUrl Applied to Img and Link types (as original).
<Cfg>ReversedTree
<Cfg>DynamicBorder Except option value 1 does the same as 2 (checks all rows and columns).
<Cfg>FormulaEditing If set and non-zero, convertor will search for formulas (EFormula attributes or cell values with '=').
<Cfg>MainCol Main column for indentation of child rows of a row Tree.
<Cfg>MainCol Main column for indentation of child rows of a row Tree.
Column / Row / cell attributes
<C>CanExport
<I>CanExport Except option value 2 - only its children.
<C> <cell>ExportFormat
<C> <cell>ExportStyle Supported CSS: background-color (colorname or #hex), text-align, vertical-align, white-space (wrap).
<cell>ExportValue
<cell>EFormula See Editable cell formulas - supported features.
<I cell>Visible
<Space cell>Visible
<I>MidHtml
<I>MidHtml2
<I>LeftHtml
<I>RightHtml
<C> <cell>Format See Text format - supported features.
<C> <cell>Format See Number format - supported and unsupported features.
<C> <cell>Format See Date format - supported and unsupported features.
Fired API events
API eventOnGetExportValue Called after the Xlsx exporter receives a cell value (or ExportValue if present), the value is passed as the 4th parameter.
HTML tags
Meaning of the following tags will be applied during conversion (when used with a cell content), other tags will be either stripped or converted to plain text, depending on conversion configuration (offered in a dialog before actual conversion).

<b>bold text
<i>italic style
<u>underlined text
<s>strikethrough
<span style="color: xxx">coloured text
<a href="xxx">link
<img>image

Nested tags are not supported yet.
Text format
Text Format features are applied on text content during conversion, not exported as a cell format mask.

Supported features are LetterType, Prefix, Postfix, Search, Replace, Flags;
- NoFormatEscape conf option is not supported yet - if Replace contains a supported HTML tag, the content is always HTML-formatted.

JSON as a value of the Text Format is supported.
Number format
Supported Number Format codes.
Standard format

Standard format is not supported yet.
User format

TODO: some of these features are converted but the results behaves differently - describe the differences.

0Place for a digit, displays digit or 0. If there are more digits than count of 0 and # in integer part, all the rest digits are written left to the first 0 or #.
#Place for a digit, displays digit or nothing if there are no more digits. Has sense only for decimal part or exponent definition.
Note:
Excel always displays the decimal separator even thought the decimal part is empty.
. (Dot) Decimal separator. Displays decimal separator defined in file Text.xml, tag <Format>, attribute DecimalSeparator. (dot by default).
Can be only used only once.
, (Comma) This character has two meanings:
If this is placed between any digits characters ('0' or '#') left to decimal separator, there will all three digits separated by thousand separator defined in file Text.xml, tag <Format>, attribute GroupSeparator. (comma by default).
Unsupported:
If this is placed between last digit and decimal separator (or to the end if decimal separator is not used), the value will be divided by 1000.
% Place for '%' character (it is defined in file Text.xml, tag <Format>, attribute Percent). If it is present, the number is also multiplied by 100.
E, e, E-, E+, e-, e+    Result will use exponential notation. To this location is placed 'E' or 'e' letter followed by digits of exponent.
; (Semicolon) There can be up to three different formats separated by semicolon.
The first format is used for positive numbers (and for 0 if the third format missing), second for negative numbers (without minus sign) and third for 0.
Remember, from the negative part is read only string before number and after the number, all other (the number format) is used always from positive part.
So the negative part can be used only to remove, replace or change position of the minus or change CSS attribute like color by the prefix and postfix.
\ Escape character, the next character is placed to output without any changes. Use to place format characters as 0 # . , E e + - \ " ' %.
'xxx' or "xxx"    Characters in quotes or double quotes are placed to output without any changes. Use to place format characters as 0 # . , E e + - \ " ' %.

Date format
Supported Date Format codes.

Note that names of days and months (and case of the first letter of the name) and AM/PM designator in XLSX are dependent on local language settings, so they will be usually translated. The export dialog offers option to enforce particular language - if set, it will be applied to all the used format codes.
Empty format

Filling-in the default English date and/or time format (depending on date and/or time being non-zero) format if the Format is empty is supported.
Standard format

dShort date("M/d/yyyy")
DLong date("d. MMMM yyyy")
tShort time("H:mm")
TLong time("H:mm:ss")
fLong date + short time("d. MMMM yyyy H:mm")
F Long date + long time("d. MMMM yyyy H:mm:ss")
gShort date + short time("M/d/yyyy H:mm")
GShort date + long time("M/d/yyyy H:mm:ss")
m, MDay and month("d. MMMM")
sSortable date time("yyyy-MM-ddTHH:mm:ss")
uUniversal sortable date time("yyyy-MM-dd HH:mm:ssZ")Note: timezone offset is not supported, the "Z" will be literal

Standard formats with fixed meaning

r, RRFC1123for example: Tue, 13 Jan 2004 18:12:34 GMT
y, YMonth and yearfor example: January 2004.
UUniversal date timefor example: 13. January 2004 17:12:34. This date time is converted to GMT !
User format

:Place for time separator, defined in file Text.xml, tag <Format>, attribute TimeSeparator. (colon by default).
/Place for date separator, defined in file Text.xml, tag <Format>, attribute DateSeparator. (slash by default).
dMonth days 1 - 31
ddMonth days 01 - 31
dddWeekdays Sun - Sat
ddddWeekdays Sunday - Saturday
ddddddMonth days 1st - 31st
MMonth 1 - 12
MMMonth 01 - 12
MMMMonth Jan - Dec
MMMMJanuary - December
yyYear 00 - 99
yyyyYear 0000 - 9999
hHours 1 - 12
hhHours 01 - 12
HHours 0 - 23
HHHours 00 - 23
mMinutes 0 - 59
mmMinutes 00 - 59
sSeconds 0 - 59
ssSeconds 00 - 59
tFirst letter of AM/PM designator, dependent on local language settings.
ttAM/PM designator, dependent on local language settings.
\Escape character.
'xxx' or "xxx"Characters in quotes or double quotes are placed to output without any changes.
%Place before format when use one character user format like 'd' (=> '%d') to not be taken as standard format.
Calculations - editable cell formulas
Supported Editable cell formula features.

Xlsx convertor recognizes only default values of relevant settings: FormulaRangeSeparator [:] FormulaValueSeparator [,] FormulaAbsolute [$]

Excel numeric functions (sum, etc.) ignores numbers stored as text, so ensure a numeric type is set on the TreeGrid side (or convert it manually in Excel).

Note if a formula contains a cell with an erroneous value (for example division by zero, unknown function name, indistinguishable value), the whole computation is affected in Excel (contrary to the TreeGrid where it's simply ignored).

Unsupported features

List of unsupported features. Helpful to make sure which features won't be converted as expected and how the result will look like.

Custom text in panels & headers XLSX does not support changing values in the left panel (with row numbers) resp. the top bar (with col names), TreeGrid's left panel resp. top bar will be converted as a normal row/col.
Cell types Enums, Checkboxes, Buttons as cell types are not supported by XLSX.
Enum will be converted to an actual (selected) value (as a literal).
Checkbox will be converted to 0/1 according to its state (as a number).
Button will be converted to a literal if it's textual or an image if it's image-based.
HTML tags Nested tags are not supported yet.
Number format
Unsupported Number Format codes.
Standard format

Standard format is not supported yet.
User format

8Hidden digit, the digit will not be displayed.
, The second meaning is not supported:
If this is placed between last digit and decimal separator (or to the end if decimal separator is not used), the value will be divided by 1000.

Date format
Unsupported Date Format codes.
These character codes will be replaced by an "unknown code placeholder" - a configuration option available in the export dialog, defaulty "?" (question mark).
Standard format

uUniversal sortable date time("yyyy-MM-dd HH:mm:ssZ")Note: timezone offset is not supported, the "Z" will be literal

User format

dddddWeekdays S - S
dddddddYear weeks 1 - 52
ddddddddYear weeks 01 - 52 (new 9.0)
Dnot used
DDThe rest of days in week, in count of weeks from 1/1/1970 (it is not weekday!) (new 6.1)
DDDYear day 0 - 365 (new 6.1)
DDDDCount of days from 1/1/1970, for duration in days (new 6.1)
DDDDDCount of weeks from 1/1/1970, for duration in weeks, see DD (new 6.1)
DDDDDDTenths of month days: empty,1,2,3 (new 6.3)
DDDDDDDMonth days: 1-9,0-9,0-9,0-1 (new 6.3)
MMMMMYear quarters, I, II, III, IV
MMMMMMYear halves, I, II
yYear 0 - 99
yyyCount of years from 1/1/1970, for duration in days (new 6.1)
hhhCount of hours from 1/1/1970 00:00:00, for duration in hours (new 6.1)
hhhhTenths of hours empty or 1 (new 6.3)
hhhhhHours 1-9, 0-2 (new 6.3)
HHHnot used
HHHHTenths of hours empty or 1 (new 6.3)
HHHHHHours 0-9, 0-9, 0-3 (new 6.3)
mmmCount of minutes from 1/1/1970 00:00:00, for duration in minutes (new 6.1)
mmmmTenths of minutes 0 - 5 (new 6.3)
mmmmmMinutes 0 - 9 (new 6.3)
sssCount of seconds from 1/1/1970 00:00:00, for duration in seconds (new 6.1)
ssssTenths of seconds 0 - 5 (new 6.3)
sssssSeconds 0 - 9 (new 6.3)
fHundreds of milliseconds, 0 - 9 (new 6.3)
ffTenths of milliseconds 00 - 99 (new 6.3)
fffMilliseconds - 000 - 999 (new 6.3)
ffffTenths of milliseconds 0 - 9 (new 6.3)
fffffMilliseconds - 0 - 9 (new 6.3)
zTimezone hours -12, +0, +13
zzTimezone hours -12, +00, +13
zzzTimezone hours and minutes, -12:00, +0:00, +13:00

Problematic features

List of features with behavioral differences from what might be expected.

Text wrapping XLSX supports wrapping text according to column width (or not at all) - apart from HTML, text cannot be wrapped according to newlines only.