CkCsv Java Programming Reference Documentation
CkCsv
Object Creation
CkCsv obj = new CkCsv();
Properties
// Returns a boolean value get_Crlf( )
// newVal is a boolean (input) put_Crlf( newVal )
If true, then CRLF line endings are used when saving the CSV to a file or to a string (i.e. for the methods SaveFile, SaveFile2, SaveToString). If false then bare LF line-endings are used.
// str is a CkString (output) get_Delimiter( str )
// newVal is a string (input) put_Delimiter( newVal )
The character that separates fields in a record. It is a comma by default.
If the Delimiter property is not explicitly set, the CSV component will detect the delimiter when loading a CSV.
(Semicolons are typically used in locales where the comma is used as a decimal point.)
// Returns a boolean value get_HasColumnNames( )
// newVal is a boolean (input) put_HasColumnNames( newVal )
Set to true prior to loading a CSV if the 1st record contains column names. This allows the CSV parser to correctly load the column names and not treat them as data.
// str is a CkString (input) LastErrorHtml( str )
Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
// str is a CkString (input) LastErrorText( str )
Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.Concept of LastErrorText LastErrorText Standard Information
// str is a CkString (input) LastErrorXml( str )
Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
// Returns an integer value get_NumColumns( )
The number of columns in the 1st row, which may be the row containing column names if HasColumnNames is true.
// Returns an integer value get_NumRows( )
The number of data rows. If the CSV has column names, the 1st row is not included in the count. Also, empty lines containing only whitespace characters that follow the last non-empty row are not included.
// Returns a boolean value get_Utf8( )
// b is a boolean (input) put_Utf8( b )
When set to true, all "const char *" arguments are interpreted as utf-8 strings. If set to false (the default), then "const char *" arguments are interpreted as ANSI strings.
Also, when set to true, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to false, all "const char *" return values are ANSI strings.
Methods
// row is an integer (input) // col is an integer (input) // outStr is a CkString (output) // Returns a boolean value GetCell( row, col, outStr )
Returns the contents of the cell at row, col. Indexing begins at 0. (The topmost/leftmost cell is at 0,0) Returns true for success, false for failure.
// index is an integer (input) // outStr is a CkString (output) // Returns a boolean value GetColumnName( index, outStr )
Returns the name of the Nth column. Returns true for success, false for failure.
// columnName is a string (input) // Returns an integer value GetIndex( columnName )
Returns the column index for a given column.
// row is an integer (input) // Returns an integer value GetNumCols( row )
Returns the number of columns for a specific row. If the row is larger than the number of rows in the CSV, a zero is returned.
// filename is a string (input) // Returns a boolean value LoadFile( filename )
Loads a CSV from a file. It is assumed that the CSV file contains ANSI characters. Returns true for success, false for failure.
// filename is a string (input) // charset is a string (input) // Returns a boolean value LoadFile2( filename, charset )
Loads a CSV from a file. The charset specifies the character encoding of the CSV file. A list of supported character encodings may be found on this page: Supported Charsets. Returns true for success, false for failure.
// csvData is a string (input) // Returns a boolean value LoadFromString( csvData )
Loads a CSV document from an in-memory string variable. Returns true for success, false for failure.
// filename is a string (input) // Returns a boolean value SaveFile( filename )
Saves a CSV to a file. The output file is written using the ANSI character encoding. Returns true for success, false for failure.
// filename is a string (input) // charset is a string (input) // Returns a boolean value SaveFile2( filename, charset )
Saves a CSV to a file. The charset specifies the character encoding to use for the CSV file. The text data is converted to this charset when saving. A list of supported character encodings may be found on this page: Supported Charsets. Returns true for success, false for failure.
// filename is a string (input) // Returns a boolean value SaveLastError( filename )
Saves the last-error information (the contents of LastErrorXml) to an XML formatted file.
// outStr is a CkString (output) // Returns a boolean value SaveToString( outStr )
Writes the entire CSV document to a string variable. Returns true for success, false for failure.
// row is an integer (input) // col is an integer (input) // content is a string (input) // Returns a boolean value SetCell( row, col, content )
Sets the contents for a single cell in the CSV. The content may include any characters including CRLF's, double-quotes, and the delimiter character. The Save* methods automatically double-quote fields with special chars when saving. The Load* methods automatically parse double-quoted and/or escaped fields correctly when loading.
// index is an integer (input) // columnName is a string (input) // Returns a boolean value SetColumnName( index, columnName )
Sets the name of the Nth column. The first column is at index 0. This method would only return false if an invalid index is passed (such as a negative number). Returns true for success, false for failure.
// Returns a string delimiter( )
The character that separates fields in a record. It is a comma by default.
If the Delimiter property is not explicitly set, the CSV component will detect the delimiter when loading a CSV.
(Semicolons are typically used in locales where the comma is used as a decimal point.) Returns a null on failure
// row is an integer (input) // col is an integer (input) // Returns a string getCell( row, col )
Returns the contents of the cell at row, col. Indexing begins at 0. (The topmost/leftmost cell is at 0,0) Returns a null on failure
// index is an integer (input) // Returns a string getColumnName( index )
Returns the name of the Nth column. Returns a null on failure
// Returns a string lastErrorHtml( )
Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
// Returns a string lastErrorText( )
Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.Concept of LastErrorText LastErrorText Standard Information
// Returns a string lastErrorXml( )
Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
// Returns a string saveToString( )
Writes the entire CSV document to a string variable. Returns a null on failure
|