[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Grids' (#lcl)

TCustomStringGrid.SaveToCSVFile

Saves grid content as comma-separated values in the specified file name.

Declaration

Source position: grids.pas line 1816

public procedure TCustomStringGrid.SaveToCSVFile(

  AFileName: string;

  ADelimiter: Char = ',';

  WriteTitles: Boolean = True;

  VisibleColumnsOnly: Boolean = False

);

Arguments

AFileName

  

File name (with optional path) where CSV data is stored.

ADelimiter

  

Delimiter used between cell values in CSV output; default is Comma (',').

WriteTitles

  

Indicates if column captions are written as the first row of CSV data in the file. False omits column titles in the output.

VisibleColumnsOnly

  

Indicates if only visible columns are included in the CSV output.

Description

SaveToCSVFile is a method used to store the contents of the grid control as comma-separated values in the specified file name.

AFileName contains the qualified path and file name where the CSV data is stored.

ADelimiter is the character used as the delimiter between cell values on each row. The default value is ',' (Comma)(Decimal 44), but can be changed to another value if needed.

WriteTitles indicates whether column titles are written at the beginning of the file. When set to True, column headers are included in the output. If the Columns collection has been enabled, the titles are read from the TGridColumn instances in the collection. If Columns has not been enabled, the cells in the FixedRows are written. When set to False, titles are omitted from the values output to the file. The default value for the property is True.

VisibleColumnsOnly indicates whether the CSV output contains only visible columns on the grid. This capability is enabled when the Columns collection is used to defined the columns and their visibility. When set to True, any TGridColumn instance with its Visible property set to True is included in the output.

If Columns has not been enabled, all of the columns are by default visible and written to the file - regardless of the value in the argument. The default value for the argument is False, and allows all columns to be written to the output file.

SaveToCSVFile creates a temporary TFileStream instance and calls SaveToCSVStream to process rows the and columns in the grid.

Use SaveToCSVStream to save the grid content as comma-separated values to a TStream instance.

Use LoadFromCSVStream or LoadFromCSVFile to load the content in the grid control from comma-separated values in a stream or file.

See also

TCustomStringGrid.SaveToCSVStream

  

Saves grid content as comma-separated values in the specified stream instance.

TCustomStringGrid.LoadFromCSVStream

  

Loads the grid content from the delimited values in AStream.

TCustomStringGrid.LoadFromCSVFile

  

Loads the grid from a file with delimited values for the columns and rows.

TCustomStringGrid.Rows

  

Provides indexed access to the list of column values for the specified row number.

TCustomStringGrid.Cells

  

Provides indexed access to a cell value by its column and row number.

TCustomDrawGrid.FixedRows

  

Number of the fixed rows in the grid.

TCustomDrawGrid.Columns

  

Definitions for the columns displayed the grid.

TGridColumns.Enabled

  

Indicates if the column collection is enabled.

TGridColumn.Title

  

Contains the attributes for the title in the fixed header for the column.


Version 3.2 Generated 2024-02-25 Home