Export files
FastGrid documentation
Export data format. It can be "
xlsx" (MS Excel workbook with multiple sheets), "
csv" (comma and linefeed separated plain text without styles), "
html" (MS Excel compatible HTML).
List of available formats for export menu. It can contain list (comma separated string or array) of formats possible for
ExportFormat.
File name under the grid will be exported. By default it is the
Book id or "$ExportName".
Which rows and columns are exported to xlsx / html / csv.
0 -
none - exports nothing,
1 -
focused cell(s) - exports focused cells only,
2 -
selected rows / columns or
focused cell(s) - exports selected rows and chosen rows with selected columns and chosen columns.
If no columns selected, exports selected rows and chosen rows with all columns except not chosen columns.
If no rows selected, exports selected columns with all rows except not chosen rows.
If no selection, exports focused cells.
3 -
selected rows / columns or
focused row(s) - like
2, but if no selection, exports focused rows with all columns except not chosen columns.
If row selection is restricted and column selection is permitted, exports focused columns with all rows except not chosen rows.
4 -
focused cells or
selected rows / columns or
focused cell - exports focused cells if permitted focusing rectangle by
Focus>=
2, otherwise like
2.
5 -
focused cells or
selected rows / columns or
focused row(s) - exports focused cells if permitted focusing rectangle by
Focus>=
2, otherwise like
3.
6 -
all rows and columns - exports all rows and all columns except those not chosen in export menu.
Comma separated list or array of row ids that will be exported as chosen rows according to
Exporting.
If the item starts by "
-", it is marked as not chosen and is not exported as not chosen rows according to
Exporting.
If there is item named "
-", it represents all applicable rows as not chosen.
If there is item named "
*", it represents all applicable rows as chosen. For example "*,-Row3" chooses all rows except Row3.
Comma separated list or array of column ids that will be exported as chosen columns according to
Exporting.
If the item starts by "
-", it is marked as not chosen and is not exported as not chosen columns according to
Exporting.
If there is item named "
-", it represents all applicable columns as not chosen.
If there is item named "
*", it represents all applicable columns as chosen. For example "*,-Col1" chooses all columns except Col1.
Which rows are exported:
NoExport - exports also rows with
NoExport =
1.
Collapsed - exports also collapsed children.
Hidden - exports also manually hidden rows.
Filtered - exports also filtered rows.
Deleted - exports also deleted rows.
Parents - exports also all parents of exported rows, if exporting only selected rows.
Children - exports also all children of exported rows, if exporting only selected rows.
Block - exports also other rows in
Block.
Which columns are exported:
NoExport - exports also columns with
NoExport =
1.
Collapsed - exports also collapsed children.
Hidden - exports also manually hidden columns.
Filtered - exports also filtered columns.
Deleted - exports also deleted columns.
Parents - exports also all parents of exported columns, if exporting only selected columns.
Children - exports also all children of exported columns, if exporting only selected columns.
Block - exports also other columns in
Block.
Controls exporting multiple column sets to xlsx, their column span.
0 - columns are exported standalone, every column in every set is exported to single column.
-1 - calculates the destination columns to correctly accomodate all set columns, so all the columns are exported with their exact widths.
-2 - chooses the base set as the set with the highest count of columns and spans the columns in other sets as close to destination columns as possible.
-3 - chooses the base set as the set with the highest count of columns, but exports all set columns one by one without span.
If set to column set id or index, this column set is exported as base, one exported column per one destination column, and the other column set columns are spanned as close to destination columns as possible.
If set to number >= 10, it specifies width of destination columns (e.g. 64 for base MS Excel width) and all exported set columns are spanned as close as possible to the destination columns.
It is set to -1, if exporting column margin is set by ExportSizes = ColMargin.
It is set to -3, if exporting column widths is not permitted by ExportSizes = Width.
If and how the cell values are copied to HTML format (
ExportFormat = "
html") - html format with values and styles.
Values can contain html code if set
ExportStyles flag
Html.
0 - no,
1 - raw values with
Format attribute,
2 - values in editable format,
3 - values in display format,
4 - empty values,
5 - empty values with
Format attribute.
If and how the cell values are copied to HTML format (
ExportFormat = "
html") - html format with values and styles.
Values can contain html code if set
ExportStyles flag
Html.
0 - no,
1 - raw values with
Format attribute in
mso-number-format Excel CSS attribute and in
fg-format FastGrid CSS attribute,
2 - values in editable format,
3 - values in display format,
4 - empty values,
5 - empty values with
Format attribute in
mso-number-format Excel CSS attribute and in
fg-format FastGrid CSS attribute.
If and how the cell values are exported to CSV format (
ExportFormat = "
csv") - text format with values.
Values are always copied without html code.
0 - no,
1 - raw values,
2 - values in editable format,
3 - values in display format.
If and how the cell styles are exported to xlsx or html. It can contain these keywords:
Align,
VertAlign,
Wrap,
Indent,
Rotate,
NoEdit,
Link,
Border,
Color,
Pattern,
TextColor,
TextStyle,
TextLine,
TextSize,
TextFont - if set, exports given cell attributes. If set with keyword
RowAttr /
ColAttr exports also the attributes set in row and column.
Formula - exports cell editable formulas.
Tip - exports
Tip attribute to
xlsx as comment or to
html as title.
Link - exports
Link attribute to
xlsx as Excel hyperlink or to
html as <a>.
State - exports state background colors.
Html - exports cell html.
RowAttr - exports also row and default row attributes according to other keywords.
ColAttr - exports also column and default column attributes according to other keywords.
CellAttr - exports to
xlsx the row and column attributes also to the whole rows and columns, not only to cells.
Calculated - exports also calculated cell attributes from default cells.
ColorBorder - sets default cell border for cells with background color, if set keywords
Border and
Color.
DefaultBorder - exports cell default border, in xlsx it shows the grid lines, in html it adds border to all cells without border.
Bool - exports Bool type as BoolTexts also for
ExportXlsx =
1,
ExportHtml =
1 and
ExportCsv =
1.
Tree - exports tree to xlsx outline.
! Cfg flags
ExportSizes
["Width,Height,RowSpan,ColSpan"] / ["Width,Height,RowSpan,ColSpan,Spanned"] GetCfgAttr SetCfgAttr
If and how the row heights and column widths and their span and margins are exported:
Height - exports row heights.
Width - exports column widths.
RowSpan - exports row span.
It can remarkably slow down opening the xlsx in Excel!
ColSpan - exports column span.
It can remarkably slow down opening the xlsx in Excel!
Spanned - if exports row or column span to xlsx, it exports also hidden spanned cells with their attributes.
RowMargin - exports row margin.
Ignored if not set Height.
ColMargin - exports column margin. If set, sets
ExportColSet =
-1.
Ignored if not set Width.
RestMargin - exports row rest margin.
HideRows - hides the rest of rows in sheet.
HideCols - hides the rest of columns in sheet.
AddCol - if set with
HideCols, adds one next column with 1px width to show the last borders.
CalcHeight - for
Height it exports actual row heights, calculated according to the content.
Comma separated string or array of items shown in Export menu. Set it to "" to not show the menu. It can contain "-" item as separator. Case sensitive. It can contain these keywords:
Styles (changes
ExportStyles attribute):
Color (text and background color),
Align (horizontal align),
TextStyle (text style and font),
VertAlign (vertical align),
Border (cell border),
AllStyle (Color + Align + TextStyle + VertAlign + Border),
Edit (editing permissions),
Link (cell hyperlinks),
Formula (editable formulas, but ignored by MS Excel),
CellHtml (HTML code in cell value),
State (state colors for added or changed rows and cells),
DefBorder (ColorBorder + DefaultBorder; default grid border),
Tree (tree symbols to xlsx),
Comment (cell Tip attribute),
Rows and columns: (changes
ExportRowsType and / or
ExporColsType:
Collapsed (children of collapsed parents),
Hidden (manually hidden),
Filtered (hidden by filter),
AllHidden (Collapsed + Hidden + Filtered, all hidden by any reason),
Deleted (deleted, but not removed),
Children (also all children),
Parent (also all parents),
NoExport (also rows and columns with
NoExport =
1, in book it means row and column indexes, only for
ExportFormat = "html"),
CollapsedRows,
HiddenRows,
FilteredRows,
AllHiddenRows,
DeletedRows,
ChildRows,
ParentRows,
NoExportRows (control only
ExportRows),
CollapsedCols,
HiddenCols,
FilteredCols,
AllHiddenCols,
DeletedCols,
ChildCols,
ParentCols,
NoExportCols (control only
ExportCols).
Sizes and span (changes
ExportSizes attribute):
Height (row heights),
Width (column widths),
Size (Height + Width, row heights and column widths),
RowSpan (cell row span),
ColSpan (cell column span),
Span (RowSpan + ColSpan, cell row and column span),
RowMargin (space between rows),
ColMargin (space between columns),
Margin (RowMargin + ColMargin, all space between cells),
MarginRest (space after last column if exporting more column sets with different width),
HideRowsOut (hides all remaining rows in xlsx),
HideColsOut (hides all remaining columns in xlsx),
HideOut (HideRowsOut + HideColsOut, hides all remaining rows and columns in xlsx).
Other options:
File (changes
ExportName attribute, inputs text for exported file name),
Format (changes
ExportFormat attribute, chooses items from popup list, the items are defined in
ExportFormats attribute),
Items (changes
Exporting attribute, chooses items from popup list),
Html (changes
ExportXlsx or
ExportHtml or
ExportCsv attributes depending on chosen
ExportFormat, chooses items from popup list),
Layout (changes
ExportRows and
ExportCols attributes, chooses items from popup submenu).
Separator (changes
CsvValueSeparator attribute, chooses items from popup list, the items are defined in
CsvValueSeparators attribute),
Sheets (changes
NoExport attribute of all sheets in book, chooses items from popup list),
StyleExport (changes
StyleExport attribute, as grid style used for export instead of actual style)
To hide disabled items in the menu set:
Dialogs:{ Export:{ Script:{ HideDisabled:1 } } }.
To show the menu in two columns set:
Dialogs:{ Export:{ Script:{ Columns:2 } } }.
Only when exporting to xlsx.
If set to
0, it exports only this sheet.
If set to
1, it exports all sheets together according to their
NoExport attribute.
If set to
string as comma separated list of grid ids, exports these grids together, regardless on their
NoExport attribute.
If set, loads all children of rows with
Children attribute on export, if
ExportRowsType contains "
Collapsed".
If the grid export is restricted.
Only for ExportGrids = 1.
-2 - grid is exported always and not shown in sheets in Export menu,
-1 - grid is exported always,
0 - grid is exported only if it is not
Hidden,
1 - grid is not exported,
2 - grid is not exported and not shown in sheets in Export menu.
If exporting the row / column data to xlsx is restricted.
-1 exported always either if hidden and hidden are not exported,
0 exported,
1 not exported,
2,
not exported either if set
ExportRowsType flag
NoExport /
ExportColsType flag
NoExport.
If the row or column is exported hidden:
0 according to its actual visibility,
1 - always hidden,
2 - always visible.
If set and exports to
xlsx, exports this part rows or columns to the frozen top / left panes.
If set, used instead of
AutoRemove to get rows / columns for export when the part adds rows / columns automatically by
Auto.
If and what focused cells are expored in
xlsx.
0 - none,
1 - only focused cell,
2 - also focused rect,
3 - also other selected rects.
If the actual scroll position will be exported.
0 - no,
1 - scrolls to focused cell,
2 - actual scroll.
If the actual
Zoom value will be exported. By default is
0 on Mobile (where Zoom is preset) and
1 on all others.
Comma separated list or array of row
D ids. If set, only rows with these default will export their outline level. All other rows will export outline level by 1 higher than their nearest parent with exported level.
If set, exports all empty borders in given xlsx theme color (0 - 56).
Use for some xlsx readers that show empty border as black instead of empty.
By default set to
2 on tablets.
If floating
Images are exported.
If or which side icons will be exported.
0 - none, &
1 - all left icons, &
2 - all right icons, &
4 - all text icons.
&
8 - indents cell text to not overlay the icons. Only on the aligned side.
&
16 - reads also cell attribute
ExportIcons.
Or specify comma separated string of icon names to print only them, e.g.
ExportIcons="List,Date".
If set and set also
ExportIcons&16, it is used instead of
ExportIcons
If or which marks will be exported.
0 - none, &
1 - marks on icons layer, &
2 - marks on foreground layer, &
4 - marks on background layer.
&
8 -indents cell text to not overlay the icons. Only on the aligned side.
&
16 - reads also cell attribute
ExportMarks.
&
32 - exports backgrounds layer marks with
ExportMarksOpacity opacity for empty cells,
&
64 - exports transparent marks for &32 also for cells with value.
If set and set also
ExportMarks&16, it is used instead of
ExportMarks
Opacity for the
ExportMarks &
32.
If set, joins all images with the same align in the same column for given number rows. It will produce high images, but reduces count images in xlsx when exporting many rows.
For example if set to 1000, every 1000 rows will have maximally to 3 images per column together.
Sets
ExportMergeImages individually for given column.
If set, merges the images by
ExportMergeImages only between rows on the same tree level and given lower levels.
For example value 2 merges on the same and one lower level.
It can be set to array or comma separated string of two numbers, the second number permits also higher tree levels.
If set, saves to xlsx the svg images also as png images. For compatibility with Excel 2016 and older. Can remarkably slow down the export, if there are many images.
If exporting to xlsx is taking more than this time in milliseconds, progress message is shown during exporting.
If set to
0, the export is always synchronous and cannot be cancelled during long process.
If amount of exported spanned cells by
ExportSizes flags
ColSpan and
RowSpan reaches this limit, warning message is shown (all the cells are exported anyway).
MS Excel has a problem with opening xlsx with many spanned cells and can be very slow in such case.
Settings for exported comments in
xlsx, comma separated attributes "left,top,width,height,show,background,border".
left,
top is position of the comment relative to the right top edge of the cell, cannot be negative.
width,
height is size of the comment window.
show is 0 to hide the comments on start, 1 to show all comments on start.
background is background color of the comment window, can be any HTML color.
border is border color of the comment window, can be any HTML color or 'none'.
Default font size in exported
xlsx file. It is in
points.
Default font name in exported
xlsx file.
Zip compression level for xlsx export. Possible values
0 -
9.
0 - no compression, very fast, 5x - 10x faster than compression, but produces really big xlsx files, 5x - 10x bigger than compressed.
1 - the fastest compression, still produces reasonable file size, about 25% bigger and 2x faster than option
6.
3 - reasonable compression, about 10% bigger and 1.7x faster than option
6.
6 - good compression.
9 - maximal compression, about 3% smaller and 1.2x slower than option
6.
Tool string
D
= "Export"
Default toolbar cell to show Export icon to export chosen content to xlsx / html / csv and to show export options defined by
ExportMenu.
Actions
Export
(int target = 0)
OnClickExport
Exports the grid data to xlsx / csv / html according to the actual export settings and saves them to file.
API event bool
OnExport
(Grid grid, bool test)
Called before export started. Use it to preset export attributes.
Return true to suppress the action.
If set
test, it is called just to test if export is possible, return true to restrict the action.
API event bool
OnExported
(Grid grid, any data)
Called after exported data are created, before saved to file.
data can be Uint8Array as binary or string as text.
Return Uint8Array or string as new data to save.
Return true to suppress the action.
Export and copy to clipboard
Attributes and methods used for
export and
copy to clipboard.
!! Row bits / object
FE
[0] GetAttr
Fast export. Speeds up exporting to xlsx and html and copying to clipboard as html. It also controls some exporting behavior.
If set to
row, it can be set also as object with attributes as column ids or column defaults, e.g.
FE: { Col1:31, Col2:0, DefCol1:27 }.
1. bit | &1 | exports cell attributes. |
2. bit | &2 | exports cell attributes set in row and column. |
3. bit | &4 | normalizes exported html code. |
4. bit | &8 | exports Link. |
5. bit | &16 | exports Tip. |
6. bit | &32 | exports row span. |
7. bit | &64 | exports column span. |
8, 9. bit | &384 | default is 0; if ignored column span (by ~FE&64 or ExportSizes without ColSpan) exports the value aligned as center continuous if:
0 - is aligned left or center, 128 - also if aligned right, 256 - also if it is not spanned, but other cells are spanned due ExportSizes ColSpan, 384 - never.
Does not work for row spanned cells. |
10. bit | &512 | default is 0; if set, adds ExportStringPrefix before the value when exporting as csv/text or as xlsx/html without format. To copy dates or numbers as strings.
For ExportXlsx / ExportHtml / ExportCsv / CopyText / CopyHtml = 2 is used only for Date types, for 3 is used for all types. |
11. bit | &1024 | default is 0; exports the value either if exporting without values. |
12. bit | &2048 | default is 0; adds all cell text style attributes to exported html code. |
Cell value exported, searched or copied to clipboard instead of original cell value. Ignored if set
FV without &
16.
Excel cell format exported or copied to clipboard instead of
Format. Not used for formatting value.
Default date format used when exporting / copying to xlsx/html cell with Type="Date" and without Format.
String added before exported/copied value for
FE&
512 when exporting/copying without format.
Grid method any
GetExport
(string format = "xlsx", function func = null)
If
not set
func, returns the grid exported data according to the
format and appropriate Export... / Copy... settings.
format = "
xlsx" - returns Uint8Array as xlsx file binary data, "
html" - returns string as html data in xhtml format, "
csv" - returns string as csv data in plain text, "
copy" - returns array of two strings as [text,html] for copying to clipboard.
For error returns null.
If set
func, runs asynchronously and after finish calls
func(
any data,
bool was_async,
int error,
bool spanerror), where
data are the exported data according to the
format, the same as returned data if called without
func,
was_async is set if the function was asynchronous and displayed progress message,
error is
0 for correct full export or
>0 as real source rows exported if reached xlsx limit 1,048,576 (for
xlsx) or
-1 if not all rows were exported due memory limit (fox
xlsx),
-2 if html export is too long for clipboard and only text is produced (for
copy),
spanerror is set if exceeded
MaxExportSpan /
MaxCopySpan and the data should not (but can) be used.
Return true for success start and null for error.
Grid method string[]
ParseExportItems
(any items, bool cols, string attr, int max, bool obj)
Support method for export. Parses
items to array or object.
items are rows / columns for export or copy, e.g.
ExportRows, ... It can be comma separated string or array of the row / column ids.
cols is
1 if
items contains column ids,
0 if it contains rows.
max is maximal number in row / column attribute
ItemX, like Layout dialog
MaxItem.
If set
obj, returns object of the items by ids like object[id] = 0/1, 1 - chosen, 0 - not chosen.
If not set
obj, returns array of the item ids, the not chosen ids start by "-".
This method especially replaces special items "*" and "-" by all the applicable row / column ids.
CSV data
Settings for load, save, import and export data in CSV (comma separated values) format.
The CSV format is loaded if set
Format="csv" or Format is not set and
Url ends by ".csv".
The CSV format is imported if the file name ends by ".csv".
The CSV format is saved if set
Format="csv".
The CSV format is exported if set
ExportFormat="csv".
Separator for separating cell values in
csv data.
For input: if not set or is set to number, it is chosen according to the input data from "
,", "
;" and "
\t".
If the separator is know, set it to avoid separator searching and speed the load.
For ouput: if not set or is set to
1 it is "
,", for
2 it is "
;", for
3 it is "
\t".
String or array of characters that can be chosen as
CsvValueSeparator in Export menu.
Separator for separating row values in
csv data.
For input: if not set or it is set to number, it separates rows by any of CRLF, CR or LF.
For output: if not set or is set to
1 it is "
\r\n", for
2 it is "
\n", for
3 it is "
\r".
Quote character used in
csv data.
Row part id where the
csv data will be added.
It can be set to "DefRowPart" to use
DefRowPart.
If set to column part id, it creates required columns for added
csv data. By default it does not add the columns.
It can be set to "DefColPart" to use
DefColPart.
If set, adds "\uFEFF" to beginning of exported CSV file.