Declaration¶
Source position: csvdocument.pp line 69
type
TCSVDocument = class(TCSVHandler)
public
constructor Create;
destructor Destroy;
procedure LoadFromFile(const AFilename: string); overload;
procedure LoadFromFile(const AFilename: string; ABufferSize: Integer); overload;
procedure LoadFromStream;
procedure SaveToFile;
procedure SaveToStream;
procedure AddRow;
procedure AddCell;
procedure InsertRow;
procedure InsertCell;
procedure RemoveRow;
procedure RemoveCell;
function HasRow : Boolean;
function HasCell : Boolean;
function IndexOfCol : Integer;
function IndexOfRow : Integer;
procedure Clear;
procedure CloneRow;
procedure ExchangeRows;
procedure UnifyEmbeddedLineEndings;
procedure RemoveTrailingEmptyCells;
property DetectBOM: Boolean; {rw}
property Cells[ACol : Integer,ARow : Integer]: string; {rw}
property RowCount: Integer; {r}
property ColCount[ARow : Integer]: Integer; {r}
property MaxColCount: Integer; {r}
property CSVText: string; {rw}
end;
Inheritance¶
Description¶
TCSVDocument can be used to read a CSV file in memory using e.g. LoadFromFile, manipulate the contents using the Cells property. Additional rows can be added using AddRow, additional cells can be added using AddCell. After all is done, the SaveToFile method can be used to save the new content to file. The various properties introduced in csvreadwrite.TCSVHandler can be used to configure the format of the CSV file.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Cells | public | Array access to all cells. |
| ColCount read only | public | Return the column count for a given row. |
| CSVText | public | Return the CSV Document as a single CSV text. |
| DetectBOM | public | |
| MaxColCount read only | public | Maximum column count. |
| RowCount read only | public | Number of available rows. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| AddCell | public | Add a new cell to a row. |
| AddRow | public | Add a new row to the CSV Data. |
| Clear | public | Remove all rows. |
| CloneRow | public | Duplicate a row. |
| Create | public | Create a new instance of TCSVDocument. |
| Destroy | public | Remove the TCSVDocument instance from memory. |
| ExchangeRows | public | Exchange positions of 2 rows. |
| HasCell | public | Test if a cell exists. |
| HasRow | public | Test if a row exists. |
| IndexOfCol | public | Test whether a value exists at a given row. |
| IndexOfRow | public | Test whether a value exists at a given column. |
| InsertCell | public | Insert cell at specified position. |
| InsertRow | public | Insert row before row number aRow. |
| LoadFromFile | public | Load a CSV file into the document. |
| LoadFromStream | public | Load CSV data from a stream. |
| RemoveCell | public | Remove a cell at a particular row. |
| RemoveRow | public | Remove a row. |
| RemoveTrailingEmptyCells | public | Remove empty cells at the end of each row. |
| SaveToFile | public | Save to file on disk. |
| SaveToStream | public | Save the CSV data to stream. |
| UnifyEmbeddedLineEndings | public | Ensures all values have the same line ending/. |
See also¶
| Name | Description |
|---|---|
| LoadFromFile | Load a CSV file into the document. |
| Cells | Array access to all cells. |
| AddRow | Add a new row to the CSV Data. |
| AddCell | Add a new cell to a row. |
| SaveToFile | Save to file on disk. |
| csvreadwrite.TCSVHandler | Base class for CSV reading and writing classes. |