CsvDataLoadOptions

Inheritance: java.lang.Object

public class CsvDataLoadOptions

Represents options for parsing CSV data.

To learn more, visit the LINQ Reporting Engine documentation article.

Remarks:

An instance of this class can be passed into constructors of CsvDataSource.

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Constructors

ConstructorDescription
CsvDataLoadOptions()Initializes a new instance of this class with default options.
CsvDataLoadOptions(boolean hasHeaders)Initializes a new instance of this class with specifying whether CSV data contains column names at the first line.

Methods

MethodDescription
getCommentChar()Gets the character that is used to comment lines of CSV data.
getDelimiter()Gets the character to be used as a column delimiter.
getQuoteChar()Gets the character that is used to quote field values.
hasHeaders()Gets a value indicating whether the first record of CSV data contains column names.
hasHeaders(boolean value)Sets a value indicating whether the first record of CSV data contains column names.
setCommentChar(char value)Sets the character that is used to comment lines of CSV data.
setDelimiter(char value)Sets the character to be used as a column delimiter.
setQuoteChar(char value)Sets the character that is used to quote field values.

CsvDataLoadOptions()

public CsvDataLoadOptions()

Initializes a new instance of this class with default options.

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

CsvDataLoadOptions(boolean hasHeaders)

public CsvDataLoadOptions(boolean hasHeaders)

Initializes a new instance of this class with specifying whether CSV data contains column names at the first line.

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Parameters:

ParameterTypeDescription
hasHeadersboolean

getCommentChar()

public char getCommentChar()

Gets the character that is used to comment lines of CSV data.

Remarks:

The default value is ‘#’ (number sign).

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Returns: char - The character that is used to comment lines of CSV data.

getDelimiter()

public char getDelimiter()

Gets the character to be used as a column delimiter.

Remarks:

The default value is ‘,’ (comma).

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Returns: char - The character to be used as a column delimiter.

getQuoteChar()

public char getQuoteChar()

Gets the character that is used to quote field values.

Remarks:

The default value is ‘"’ (quotation mark).

Double the character to place it into quoted text.

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Returns: char - The character that is used to quote field values.

hasHeaders()

public boolean hasHeaders()

Gets a value indicating whether the first record of CSV data contains column names.

Remarks:

The default value is false .

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Returns: boolean - A value indicating whether the first record of CSV data contains column names.

hasHeaders(boolean value)

public void hasHeaders(boolean value)

Sets a value indicating whether the first record of CSV data contains column names.

Remarks:

The default value is false .

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Parameters:

ParameterTypeDescription
valuebooleanA value indicating whether the first record of CSV data contains column names.

setCommentChar(char value)

public void setCommentChar(char value)

Sets the character that is used to comment lines of CSV data.

Remarks:

The default value is ‘#’ (number sign).

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Parameters:

ParameterTypeDescription
valuecharThe character that is used to comment lines of CSV data.

setDelimiter(char value)

public void setDelimiter(char value)

Sets the character to be used as a column delimiter.

Remarks:

The default value is ‘,’ (comma).

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Parameters:

ParameterTypeDescription
valuecharThe character to be used as a column delimiter.

setQuoteChar(char value)

public void setQuoteChar(char value)

Sets the character that is used to quote field values.

Remarks:

The default value is ‘"’ (quotation mark).

Double the character to place it into quoted text.

Examples:

Shows how to use CSV as a data source (string).


 Document doc = new Document(getMyDir() + "Reporting engine template - CSV data destination (Java).docx");

 CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
 loadOptions.setDelimiter(';');
 loadOptions.setCommentChar('$');
 loadOptions.hasHeaders(true);
 loadOptions.setQuoteChar('"');

 CsvDataSource dataSource = new CsvDataSource(getMyDir() + "List of people.csv", loadOptions);
 buildReport(doc, dataSource, "persons");

 doc.save(getArtifactsDir() + "ReportingEngine.CsvDataString.docx");
 

Parameters:

ParameterTypeDescription
valuecharThe character that is used to quote field values.