use of com.haulmont.yarg.loaders.factory.DefaultLoaderFactory in project tutorials by eugenp.
the class DocumentController method generateDocument.
@RequestMapping(path = "/generate/doc", method = RequestMethod.GET)
public void generateDocument(HttpServletResponse response) throws IOException {
ReportBuilder reportBuilder = new ReportBuilder();
ReportTemplateBuilder reportTemplateBuilder = new ReportTemplateBuilder().documentPath("./src/main/resources/Letter.docx").documentName("Letter.docx").outputType(ReportOutputType.docx).readFileFromPath();
reportBuilder.template(reportTemplateBuilder.build());
BandBuilder bandBuilder = new BandBuilder();
String json = FileUtils.readFileToString(new File("./src/main/resources/Data.json"));
ReportBand main = bandBuilder.name("Main").query("Main", "parameter=param1 $.main", "json").build();
reportBuilder.band(main);
Report report = reportBuilder.build();
Reporting reporting = new Reporting();
reporting.setFormatterFactory(new DefaultFormatterFactory());
reporting.setLoaderFactory(new DefaultLoaderFactory().setJsonDataLoader(new JsonDataLoader()));
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
reporting.runReport(new RunParams(report).param("param1", json), response.getOutputStream());
}
use of com.haulmont.yarg.loaders.factory.DefaultLoaderFactory in project jmix by jmix-framework.
the class ReportsConfiguration method loaderFactory.
@Bean("report_LoaderFactory")
public ReportLoaderFactory loaderFactory(JmixSqlDataLoader sqlDataLoader, JmixGroovyDataLoader groovyDataLoader, JpqlDataLoader jpqlDataLoader, JmixJsonDataLoader jsonDataLoader, SingleEntityDataLoader singleEntityDataLoader, MultiEntityDataLoader multiEntityDataLoader) {
DefaultLoaderFactory loaderFactory = new DefaultLoaderFactory();
Map<String, ReportDataLoader> dataLoaders = new HashMap<>();
dataLoaders.put("sql", sqlDataLoader);
dataLoaders.put("groovy", groovyDataLoader);
dataLoaders.put("jpql", jpqlDataLoader);
dataLoaders.put("json", jsonDataLoader);
dataLoaders.put("single", singleEntityDataLoader);
dataLoaders.put("multi", multiEntityDataLoader);
loaderFactory.setDataLoaders(dataLoaders);
return loaderFactory;
}
Aggregations