Last active
August 15, 2021 08:49
-
-
Save GroupDocsGists/386745c6e850606db29ec44796406f20 to your computer and use it in GitHub Desktop.
Generate PDF and Word Reports from CSV data using Template in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate PDF Report from CSV data using TXT template in Java with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
String csvDataSource = "dataPath/Person.csv"; | |
String templateFilePath = "templatePath/template.txt"; | |
String reportFilePath = "reportsPath/reportFromCSV.pdf"; | |
// Laod CSV Data Source | |
CsvDataLoadOptions options = new CsvDataLoadOptions(true); | |
CsvDataSource datasource= new CsvDataSource(csvDataSource,options); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"persons"); | |
// Generate Report | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.assembleDocument(templateFilePath, reportFilePath, dataSourceInfo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate Word Report from CSV data using TXT template in Java with GroupDocs.Assembly API | |
// Define datasource, template, and output report files. | |
String csvDataSource = "dataPath/Person.csv"; | |
String templateFilePath = "templatePath/template.txt"; | |
String reportFilePath = "reportsPath/reportFromCSV.docx"; | |
// Load CSV Data Source | |
CsvDataLoadOptions options = new CsvDataLoadOptions(true); | |
CsvDataSource datasource= new CsvDataSource(csvDataSource,options); | |
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"persons"); | |
// Generate Report | |
DocumentAssembler assembler = new DocumentAssembler(); | |
assembler.assembleDocument(templateFilePath, reportFilePath, dataSourceInfo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment