YARG DefaultFormatterFactory compile error

Hi

I am trying to integrate generating documents programmatically using the ‘ReportTemplateBuilder’ however when I run the project I get a deploy error (although the problem appears to be any class under the yarg-2.0.18.jar library).:

import com.haulmont.yarg.formatters.factory.DefaultFormatterFactory;
^
symbol: class DefaultFormatterFactory
location: package com.haulmont.yarg.formatters.factory
1 error
FAILED

I’ve added the report module and the project external libraries in intelliJ show both:
yarg-2.0.18.jar
yarg-api-2.0.18.jar

Using intelliJ it also doesn’t show any errors.

Any help would be appreciated as I’ve spent hours trying to get to the bottom of the issue but have had no joy.

Thanks
David

Hi,

Do you use Reporting addon or only YARG?

Hi

We are trying to use both. The situation we are trying to achieve is mainly relating to letter creation for customer/suppliers etc. In the main they will be fixed templates which the standard reporting is great for. However, we require custom letters that will be written at the point of creation (although will be based on a standard template that might just consist of a header/footer etc). These letters will also need to be stored against the entity for future reference. The standard templates again this works great, however the problem arises with template content that needs to be changed on the fly depending on the circumstances. The industry we are supplying uses MS word heavily and there is an expectation that letters will be created in this and the functionality of the standard reporting does not make it easy for non-technical people to manage/change templates for custom letters. In reality because of the complexity for a non-technical person managing reports/templates in the system it s likely that the user will simply print the report, display it in word and then change the content. This will result in either the user having to manually uploading the new custom created letter into the system or the more likely scenario, that they simply won’t bother. This will result in letters stored in the system being inaccurate. We need an easy way for users to manage templates/custom letter creation prior to them printing to ensure the correct letter is stored directly in the system at point of print.

We thought a way round this would be to create a basic template using the reporting addon and then programmatically (directly through yarg) call the template and change the content based on user input that we could have a prompt for in our system as part of the print process.

We are also wondering if there is an easy way to add/change templates (in the standard report addon) at point of creation rather than having to go through the report management functionality. As already advised, our customers are not technical people and the standard reporting addon is way too complicated for them and there is a high possibility that templates will be deleted, changed, broken etc etc.

If I’ve misunderstood something, you have any advice or there is something already available to support this then please do let me know.

Thanks in advance.
David

Hi David,

com.haulmont.reports.app.service.ReportService is the API that allows to execute reports programmatically. One of the methods execute a report with the specified ReportTemplate object.

ReportOutputDocument createReport(Report report, ReportTemplate template, Map<String, Object> params).

I think you can try this way:

  • Сreate report template at runtime:
        byte[] content = //create template DOCX as bytes array
        ReportTemplate reportTemplate = metadata.create(ReportTemplate.class);
        reportTemplate.setContent(content);
        reportTemplate.setCode("reportCode");
        reportTemplate.setReportOutputType(ReportOutputType.DOCX);
        reportTemplate.setName("template.docx");
  • Configure new report using Reporting UI and run created report programmatically with newly created dynamic template.

Thanks Audrey for the quick response. Makes sense and will check it out.