com.aspose.words
Class CsvDataLoadOptions

java.lang.Object
    extended by com.aspose.words.CsvDataLoadOptions

public class CsvDataLoadOptions 
extends java.lang.Object

Represents options for parsing CSV data.

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

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

Example:

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");

Constructor Summary
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.
 
Property Getters/Setters Summary
chargetCommentChar()
voidsetCommentChar(char value)
           Gets or sets the character that is used to comment lines of CSV data.
chargetDelimiter()
voidsetDelimiter(char value)
           Gets or sets the character to be used as a column delimiter.
booleanhasHeaders()
voidhasHeaders(boolean value)
           Gets or sets a value indicating whether the first record of CSV data contains column names.
chargetQuoteChar()
voidsetQuoteChar(char value)
           Gets or sets the character that is used to quote field values.
 

Constructor Detail

CsvDataLoadOptions

public CsvDataLoadOptions()
Initializes a new instance of this class with default options.

Example:

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

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

Example:

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");

Property Getters/Setters Detail

getCommentChar/setCommentChar

public char getCommentChar() / public void setCommentChar(char value)
Gets or sets the character that is used to comment lines of CSV data. The default value is '#' (number sign).

Example:

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");

getDelimiter/setDelimiter

public char getDelimiter() / public void setDelimiter(char value)
Gets or sets the character to be used as a column delimiter. The default value is ',' (comma).

Example:

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");

hasHeaders/hasHeaders

public boolean hasHeaders() / public void hasHeaders(boolean value)
Gets or sets a value indicating whether the first record of CSV data contains column names. The default value is false.

Example:

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");

getQuoteChar/setQuoteChar

public char getQuoteChar() / public void setQuoteChar(char value)
Gets or sets the character that is used to quote field values.

The default value is '"' (quotation mark).

Double the character to place it into quoted text.

Example:

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");

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.