How best to override reporting method

I’m trying to customize the formatting of certain fields in Cuba Reports. To achieve this, I believe I would like to override the formatValue() method of DocxFormatter. The problem is getting the reporting library to use my modified class without having to override many other library classes. If I can somehow get the reporting library to use an overridden FormatterFactory, that would help. This class seems to be instantiated using Spring.

I could really use some advice on how best to proceed. The change I need to make only involves one method, but trying to get the library to utilize the overridden version is proving to be quite a mess. Suggestions? Thanks so much

Hi Eric,

  1. You can create custom FormatterFactory class, like this:

public class ExtFormatterFactory extends CubaFormatterFactory {
    public ExtFormatterFactory() {
        FormatterCreator docxCreator = new FormatterCreator() {
            public ReportFormatter create(FormatterFactoryInput factoryInput) {
                DocxFormatter docxFormatter = new ExtDocxFormatter(factoryInput);
                if (useOfficeForDocxPdfConversion) {
                return docxFormatter;
        formattersMap.put("docx", docxCreator);

where ExtDocxFormatter is an overridden docx formatter.
2. Register an overridden FormatterFactory in spring.xml file in the core module:

<bean id="reporting_lib_FormatterFactory"
          class="<path to class>ExtFormatterFactory">
        <property name="useOfficeForDocxPdfConversion" value="${reporting.openoffice.docx.useOfficeForPdfConversion?:false}"/>
        <property name="officeIntegration" ref="reporting_lib_OfficeIntegration"/>
        <property name="defaultFormatProvider" ref="reporting_lib_CubaFieldFormatProvider"/>


Thanks so much!! Worked perfectly.