I have been working on a pair of macros to try to get around the current weakness (failure) of Report Builder to generate Charts in Base Reports, for SQL databases in particular. I prefer to embed charts in Reports, rather than in Forms, because it is so much easier to add commentary and description to reports intended for printing:
A) Create (or re-create) a Chart report in Report Builder. To allow quick regeneration of Chart reports each time LO is upgraded - and Base chart reports get broken.
The attached Base file testodb0.odb uses built-in HSQLDB and includes two reports:
- ‘Sales_Report’ created in Report Builder.
- ‘Sales_Report_by_code’ created by running macro ‘Sales_Report_ORB’ in module ‘Sales_Report_ORB’ - or use custom menu ReportMacros (to the right of Help).
The ‘Sales_Report_ORB’ macro fails to include the horizontal line (actually a thin Rectangle shape) in the Page Header. Does anyone have any ideas on why not?
Apart from this, the two reports look identical when inspected in Report Builder but both suffer the same fate when executed (in LO v5.3.6.1 colours revert to defaults, in LO v6.0.1.1 the Chart does not appear). So this would seem to be a dead end - unless other people have a different experience?
B) Create a Base report directly in Writer, bypassing Report Builder and its integration into LO. To be more resilient against LO upgrades, but report changes will have to be done in code - which can be tedious.
Execute macro macro ‘Sales_Report_Writer’ in module ‘Sales_Report_Writer’ - or use custom menu ReportMacros (to the right of Help). This works well in both LO v5.3.6.1 and LO v6.0.1.1 (TDF builds under OpenSuse Linux x64). I’d be interested to hear how well it works in other versions of LO?
These macros explore many elements of a chart and of report generation which I hope may be of interest to macro coders. Chart type in these macros is a simple Pie Chart, but I also have a Stacked Area report and a grouped XY chart report which I hope to be able to post soon.
I have learnt much from other contributors whom I would like to acknowledge, including ratslinger, Villeroy, longi, Robert Großkopf.