ReportBuilder.BuildReport

ReportBuilder BuildReport method. Populates the specified template document with data from the specified source making it a ready report.

BuildReport(string, string, object, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, object data, 
    ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
dataObjectA data source object.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Shows how to fill template with data from JSON data source loaded from file using LINQ Reporting engine.

JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json", new JsonDataLoadOptions() { AlwaysGenerateRootObject = true });

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

See Also


BuildReport(string, string, SaveFormat, object, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    object data, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
dataObjectA data source object.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Shows how to fill a template from a JSON file using LINQ Reporting Engine and save the result with a specified format.

JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json", new JsonDataLoadOptions() { AlwaysGenerateRootObject = true });

ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx", ArtifactsDir + "ReportingForeachJsonDataSource.rtf", SaveFormat.Rtf, ds);

See Also


BuildReport(Stream, Stream, SaveFormat, object, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    object data, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
dataObjectA data source object.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.

Examples

Shows how to fill a template from a XML file using LINQ Reporting Engine and save the result to stream.

XmlDataLoadOptions xmlLoadOptions = new XmlDataLoadOptions();
xmlLoadOptions.AlwaysGenerateRootObject = true;
XmlDataSource ds = new XmlDataSource(MyDir + "ReportingData.xml", xmlLoadOptions);

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

See Also


BuildReport(string, string, object, string, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, object data, 
    string dataSourceName, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
dataObjectA data source object.
dataSourceNameStringA name to reference the data source object in the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

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


BuildReport(string, string, SaveFormat, object, string, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    object data, string dataSourceName, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
dataObjectA data source object.
dataSourceNameStringA name to reference the data source object in the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Class used as a data object.

public class DummyData
{
    public string Name { get; set; }
    public string Position { get; set; }
}

Shows how to fill a template from an object using LINQ Reporting Engine and save the result with a specified format.

List<DummyData> data = new List<DummyData>();
data.Add(new DummyData() { Name = "James Bond", Position = "Spy" });
data.Add(new DummyData() { Name = "John Doe", Position = "Unknown" });

ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx", ArtifactsDir + "ReportingForeachObjectDataSource.xps", SaveFormat.Xps, data, "data");

See Also


BuildReport(Stream, Stream, SaveFormat, object, string, ReportBuilderOptions)

Populates the specified template document with data from the specified source making it a ready report.

public static void BuildReport(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    object data, string dataSourceName, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
dataObjectA data source object.
dataSourceNameStringA name to reference the data source object in the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.

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


BuildReport(string, string, object[], string[], ReportBuilderOptions)

Populates the specified template document with data from the specified sources making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, object[] data, 
    string[] dataSourceNames, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
dataObject[]An array of data source objects.
dataSourceNamesString[]An array of names to reference the data source objects within the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Shows how to fill template with data using LINQ Reporting engine.

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

ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx",
    ArtifactsDir + "ReportingForeachCsvDataSource.rtf",
    new object[] { ds },
    new string[] { "data" });

See Also


BuildReport(string, string, SaveFormat, object[], string[], ReportBuilderOptions)

Populates the specified template document with data from the specified sources making it a ready report.

public static void BuildReport(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    object[] data, string[] dataSourceNames, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe output’s save format.
dataObject[]An array of data source objects.
dataSourceNamesString[]An array of names to reference the data source objects within the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.

Examples

Shows how to fill a template with data using the LINQ Reporting Engine and save the result in a specified format.

JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json");

ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx",
    ArtifactsDir + "ReportingForeachJsonDataSource.html",
    SaveFormat.Html,
    new object[] { ds },
    new string[] { "data" });

See Also


BuildReport(Stream, Stream, SaveFormat, object[], string[], ReportBuilderOptions)

Populates the specified template document with data from the specified sources making it a ready report.

public static void BuildReport(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    object[] data, string[] dataSourceNames, ReportBuilderOptions reportBuilderOptions = null)
ParameterTypeDescription
inputStreamStreamThe input file stream.
outputStreamStreamThe output file stream.
saveFormatSaveFormatThe output’s save format.
dataObject[]An array of data source objects.
dataSourceNamesString[]An array of names to reference the data source objects within the template.
reportBuilderOptionsReportBuilderOptionsAdditional report build options.

Remarks

If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.

If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.

Examples

Shows how to fill a template with data using the LINQ Reporting Engine and save the result to stream in a specified format.

JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json");

using (Stream input = File.OpenRead(MyDir + "ReportingTemplateForeach.docx"))
using (Stream output = File.Create(ArtifactsDir + "ReportingForeachJsonDataSource.svg"))
{
    ReportBuilder.BuildReport(input, output, SaveFormat.Svg, new object[] { ds }, new string[] { "data" });
}

See Also