CsvDataSource

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

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 fill template with data from CSV data source loaded from file using LINQ Reporting engine.

CsvDataLoadOptions csvLoadOptions = new CsvDataLoadOptions();
csvLoadOptions.QuoteChar = '\'';
csvLoadOptions.CommentChar = '|';
csvLoadOptions.Delimiter = ',';
csvLoadOptions.HasHeaders = true;
CsvDataSource ds = new CsvDataSource(MyDir + "ReportingData.csv", csvLoadOptions);

ReportBuilderOptions reportBuilderOptions = new ReportBuilderOptions();
reportBuilderOptions.AllowMissingMembers = true;

using (Stream input = File.OpenRead(MyDir + "ReportingTemplateForeach.docx"))
using (Stream output = File.Create(ArtifactsDir + "ReportingForeachCsvDataSource.pdf"))
{
    ReportBuilder.BuildReport(input, output, SaveFormat.Pdf, ds, "data", reportBuilderOptions);
}

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 fill template with data from CSV data source loaded from stream using LINQ Reporting engine.

string csvString = "Name,Position\r\nJames Bond,Spy";
CsvDataLoadOptions csvLoadOptions = new CsvDataLoadOptions() { HasHeaders = true };
CsvDataSource ds = new CsvDataSource(new MemoryStream(Encoding.UTF8.GetBytes(csvString)), csvLoadOptions);

ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx", ArtifactsDir + "ReportingForeachCsvDataSource.docx", ds, "data");

See Also