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

TCustomStringGrid.LoadFromCSVFile

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

Declaration

Source position: grids.pas line 1812

public procedure TCustomStringGrid.LoadFromCSVFile(

  AFilename: string;

  ADelimiter: Char = ',';

  UseTitles: Boolean = True;

  FromLine: Integer = 0;

  SkipEmptyLines: Boolean = True

);

Arguments

AFilename

  

File name with the content loaded in the method.

ADelimiter

  

Delimiter between cell values in the file; default is Comma (',').

UseTitles

  

Indicates if column captions are loaded from values in the file.

FromLine

  

Initial line number from the file loaded in the method.

SkipEmptyLines

  

Indicates if empty lines in the file are ignored in the method.

Description

LoadFromCSVFile is a method used to delimited values from the file name in AFilename. It creates a temporary TFileStream instance that is used to load values from the file by calling the LoadFromCSVStream method.

ADelimiter is a character which identifies the delimiter used between column values on a row. Its default value is ',' (Comma) (decimal 44), but can be changed to another character value if needed.

Each row of values is terminated by a Carriage Return (Decimal 13) or Line Feed (Decimal 10) character. CR+LF may also be used. When either of the characters is encountered, they are processed as an end-of-line marker.

UseTitles indicates whether the first row of values in the file are treated as fixed column titles in the grid. When set to True, each column value is stored as the caption for the corresponding entry in the Columns collection (when enabled). The Columns collection is enabled when its Count property has a positive non-zero value. If Columns are not used, the values are stored as Cell data in row 0. If UseTitles is set to False, the first row is treated as Cell data in row 0. The default value for UseTitles is True.

FromLine indicates the ordinal line number that is the first row loaded in the method. The default value is 0, and causes processing to begin at the first line. When a positive non-zero value is used, the specified number of lines are skipped by reading the corresponding number of end-of-line sequences.

SkipEmptyLines indicates whether blank lines are skipped when the row and column values are loaded in the method. The default value is True, and causes any row with a single empty column value to be skipped.

Use LoadFromCSVStream to load delimited row and column values from a TStream instance.

Use SaveToCSVFile or SaveToCSVStream to store the content in the grid as comma-separated values.

See also

TCustomStringGrid.LoadFromCSVStream

  

Loads the grid content from the delimited values in AStream.

TCustomStringGrid.SaveToCSVFile

  

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

TCustomStringGrid.SaveToCSVStream

  

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

TCustomStringGrid.Cells

  

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

TCustomDrawGrid.Columns

  

Definitions for the columns displayed the grid.

TCustomDrawGrid.ColCount

  

Number of columns in the grid.

TCustomDrawGrid.FixedRows

  

Number of the fixed rows in the grid.

TGridColumns

  

Collection used to store column definitions for a grid control.

TGridColumn.Title

  

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

LoadFromCSVFile


Version 3.2 Generated 2024-02-25 Home