CsvDataSource

CsvDataSource(string)

Creates a new data source with data from a CSV file using default options for parsing CSV data.

public CsvDataSource(string csvPath)
ParameterTypeDescription
csvPathStringThe path to the CSV file to be used as the data source.

See Also


CsvDataSource(string, CsvDataLoadOptions)

Creates a new data source with data from a CSV file using the specified options for parsing CSV data.

public CsvDataSource(string csvPath, CsvDataLoadOptions options)
ParameterTypeDescription
csvPathStringThe path to the CSV file to be used as the data source.
optionsCsvDataLoadOptionsOptions for parsing the CSV data.

Examples

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

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

CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
loadOptions.Delimiter = ';';
loadOptions.CommentChar = '$';
loadOptions.HasHeaders = true;
loadOptions.QuoteChar = '"';

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

doc.Save(ArtifactsDir + "ReportingEngine.CsvDataString.docx");

See Also


CsvDataSource(Stream)

Creates a new data source with data from a CSV stream using default options for parsing CSV data.

public CsvDataSource(Stream csvStream)
ParameterTypeDescription
csvStreamStreamThe stream of CSV data to be used as the data source.

See Also


CsvDataSource(Stream, CsvDataLoadOptions)

Creates a new data source with data from a CSV stream using the specified options for parsing CSV data.

public CsvDataSource(Stream csvStream, CsvDataLoadOptions options)
ParameterTypeDescription
csvStreamStreamThe stream of CSV data to be used as the data source.
optionsCsvDataLoadOptionsOptions for parsing the CSV data.

Examples

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

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

CsvDataLoadOptions loadOptions = new CsvDataLoadOptions(true);
loadOptions.Delimiter = ';';
loadOptions.CommentChar = '$';

using (FileStream stream = File.OpenRead(MyDir + "List of people.csv"))
{
    CsvDataSource dataSource = new CsvDataSource(stream, loadOptions);
    BuildReport(doc, dataSource, "persons");
}

doc.Save(ArtifactsDir + "ReportingEngine.CsvDataStream.docx");

See Also