Object Reference > True DBGrid Methods > ExportRows Method |
ExportRows Method
The ExportRows method exports a sequence of rows from the grid to the specified file as an HTML table.
TDBGrid.ExportRows pathname, append, rows, [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.
rows is a long integer that specifies the number of 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 ExportRows method must be preceded by a call to ExportBegin, which specifies the bookmark of the first row to be exported. Failure to call ExportBegin before ExportRows results in a trappable error.
The maximum number of rows to be exported is given by the rows argument. The actual number of rows exported may be less if the end of the data source is reached. You can use the ExportEOF property to determine if there are more rows available for export.
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.
Note
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. The output preserves as much of the grid's original formatting as possible, including colors, fonts, alignment, and relative column widths.