Deutsch Indonesia Tiếng Việt فارسی English Italiano Türkçe ไทย Español Polski Русский 日本語 Français Português العربية

DOC Generation from Templates in C#

Wordize for .NET is a professional solution for automated reporting and programmatic DOC document generation. The ReportBuilder class provides C# developers with the capability to create DOC reports using templates and LINQ syntax, which helps accelerate business intelligence processes, implement dynamic DOC content in automated document workflows.

Key Features:
  • Programmatic DOC report generation - the ReportBuilder class provides the BuildReport() method for creating DOC documents based on templates
  • Flexible data source integration - support for JSON, XML, CSV and programmatic objects (custom classes, object collections)
  • LINQ expressions application for filtering, sorting and grouping data when generating DOC
  • DOC generation parameter configuration - the ReportBuilderOptions class manages available data types, missing field handling, empty paragraph removal and other report creation parameters in DOC format
  • Export to graphics format - the BuildReportToImages() method returns DOC report pages as an array of images
  • Fluent API support for launching report creation operations through ReportBuilderContext and method chaining, adding clarity to C# code

Test the capabilities of programmatic DOC report generation in the interactive online demo presented on this page. To do this, upload a document template, data file (JSON, XML or CSV), run the operation and download the generated DOC document for verification. The provided C# code snippet is fully ready for use in your .NET project.

C#
Run code
Upload document template
Upload data file
Select output format from the list
using Wordize.Reporting;

var dataSource = new JsonDataSource("data.json");
ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, "");
using Wordize.Reporting; var dataSource = new JsonDataSource("data.json"); ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new JsonDataSource("data.json"); var imageStreams = ReportBuilder.BuildReportToImages("Input.doc", new ImageSaveOptions(SaveFormat.Doc), new[] { dataSource }, new[] { "" }); foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i))) { using var _ = stream; stream.Position = 0; using var file = File.Create($"Output_{page + 1}.doc"); stream.CopyTo(file); }
using Wordize.Reporting;

var dataSource = new XmlDataSource("data.xml");
ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, "");
using Wordize.Reporting; var dataSource = new XmlDataSource("data.xml"); ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new XmlDataSource("data.xml"); var imageStreams = ReportBuilder.BuildReportToImages("Input.doc", new ImageSaveOptions(SaveFormat.Doc), new[] { dataSource }, new[] { "" }); foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i))) { using var _ = stream; stream.Position = 0; using var file = File.Create($"Output_{page + 1}.doc"); stream.CopyTo(file); }
using Wordize.Reporting;

var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true });
ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, "");
using Wordize.Reporting; var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true }); ReportBuilder.BuildReport("Input.doc", "Output.doc", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true }); var imageStreams = ReportBuilder.BuildReportToImages("Input.doc", new ImageSaveOptions(SaveFormat.Doc), new[] { dataSource }, new[] { "" }); foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i))) { using var _ = stream; stream.Position = 0; using var file = File.Create($"Output_{page + 1}.doc"); stream.CopyTo(file); }
Run code

How to create DOC report in C#

  1. Connect the Wordize SDK to your .NET project
  2. Create a data source and call the ReportBuilder.BuildReport() method, specifying the DOC template, result file and data source in parameters
  3. Get the generated DOC document
5%