Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Last active November 15, 2021 07:21
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 conholdate-gists/ae91a46ebfd7de45a6d9c05455cda8b7 to your computer and use it in GitHub Desktop.
Save conholdate-gists/ae91a46ebfd7de45a6d9c05455cda8b7 to your computer and use it in GitHub Desktop.
Generate Reports from Excel Data in Java
String srcDocument = "C:\\Files\\template.docx";
String docReport = "C:\\Files\\Output.docx";
String dataFilePath = "C:\\Files\\Contracts_Data.xlsx";
// Set extracting of column names from the first row.
DocumentTableOptions options = new DocumentTableOptions();
options.setFirstRowContainsColumnNames(true);
// Create document table
DocumentTable table = new DocumentTable(dataFilePath, 0, options);
// Create document assembler
DocumentAssembler assembler = new DocumentAssembler();
// Assemble data and generate report
assembler.assembleDocument(srcDocument,docReport,
new DataSourceInfo(new DataStorage(), null),
new DataSourceInfo(table,"ds"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment