Object Reference > True DBGrid Methods > ExportToFile Method |
ExportToFile Method
The ExportToFile method exports the specified rows from the grid to the specified file as an HTML table.
TDBGrid.ExportToFile pathname, append, [selector], [tablewidth]
Arguments
pathname specifies the file to which grid rows are exported.
append is a Boolean that specifies whether rows are added to the end of the file.
selector is an optional RowSelectorConstants value that specifies the rows to be exported.
tablewidth is an optional variant used to qualify the generated <table> tag.
Return Value
None
The append argument should be set to True to add the table to the end of an existing file, False to overwrite the entire file. In either case, the file is created if it does not exist.
The selector argument determines the rows to be exported. It can be one of the following constant values:
0 - dbgAllRows |
All available rows are exported. If the selector argument is omitted, this value is assumed. |
1 - dbgSelectedRows |
Only selected rows are exported. The grid's SelBookmarks collection contains a bookmark for each selected row. |
2 - dbgCurrentRow |
Only the current row is exported. |
If specified, the tablewidth argument is used as the width option of the generated <table> tag. This argument is defined as a variant to accommodate both numeric and string qualifiers. For example, an integer value denotes an absolute width in pixels, while the string "75%" indicates that the table should occupy three-fourths of the available page width.
The HTML code generated by this method contains a single <table> tag with a <tr> entry for each data row and a <th> entry for each grid, split, and column caption. Normally, you will insert this table into another HTML file that serves as a template for the page to be browsed.
The output preserves as much of the grid's original formatting as possible, including colors, fonts, alignment, and relative column widths.
Note
ExportToFile is a standalone method; it should not be surrounded by calls to ExportBegin and ExportEnd. To export a subset of the available rows, use the ExportRows method instead of ExportToFile.