Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created August 15, 2021 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/39a6cdabd9133f9b8349b78e95b56a4b to your computer and use it in GitHub Desktop.
Save GroupDocsGists/39a6cdabd9133f9b8349b78e95b56a4b to your computer and use it in GitHub Desktop.
Generate PDF and Word Reports from CSV data using Template in C#
// Generate PDF Report from CSV data using TXT template in C# with GroupDocs.Assembly API
// Define datasource, template, and output report files.
string csvDataSource = @"path/person.csv";
string templateFilePath = @"path/csv-template.txt";
string reportFilePath = @"path/csv-to-pdf-report.pdf";
// Load CSV Data Source
CsvDataSource dataSource = new CsvDataSource(csvDataSource, new CsvDataLoadOptions(true));
// Generate Report in PDF format
DocumentAssembler assembler = new DocumentAssembler();
assembler.AssembleDocument(templateFilePath, reportFilePath, new DataSourceInfo(dataSource, "persons"));
// Generate Word DOCX Report from CSV data using TXT template in C# with GroupDocs.Assembly API
// Define datasource, template, and output report files.
string csvDataSource = @"path/person.csv";
string templateFilePath = @"path/csv-template.txt";
string reportFilePath = @"path/csv-to-pdf-report.docx";
// Load CSV Data Source
CsvDataSource dataSource = new CsvDataSource(csvDataSource, new CsvDataLoadOptions(true));
// Generate Report in DOCX format
DocumentAssembler assembler = new DocumentAssembler();
assembler.AssembleDocument(templateFilePath, reportFilePath, new DataSourceInfo(dataSource, "persons"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment