GroupDocsGists
10/24/2017 - 1:09 PM

Examples-GroupDocs.Assembly.Examples.Java-src-main-java-com-groupdocs-assembly-examples-GenerateReport-definingDocumentTableRelations.java

// For complete examples and data files, please go to https://github.com/groupdocs-assembly/GroupDocs.Assembly-for-Java
// Set table column names to be extracted from the document.
DocumentTableSet tableSet = new DocumentTableSet(CommonUtilities.getDataPath(relatedTables), new ColumnNameExtractingDocumentTableLoadHandler());
 
// Define relations between tables.
// NOTE: For Spreadsheet documents, table names are extracted from sheet names.
tableSet.getRelations().add(
        tableSet.getTables().get("CLIENT").getColumns().get("ID"),
        tableSet.getTables().get("CONTRACT").getColumns().get("CLIENT_ID"));
 
tableSet.getRelations().add(
        tableSet.getTables().get("MANAGER").getColumns().get("ID"),
        tableSet.getTables().get("CONTRACT").getColumns().get("MANAGER_ID"));
 
// Pass DocumentTableSet as a data source.
DocumentAssembler assembler = new DocumentAssembler();
assembler.assembleDocument(CommonUtilities.getDataPath(docTableRelations), CommonUtilities.getOutPath("/Word Reports/out.docx"), tableSet);