Expanding the solution described in Charts in RPE Documents – the Excel way it is possible to generate Excel chart and embed them in the RPE output Word document as an OLE object. For PDF a snapshot image of the OLE will be automatically generated by RPE.
This solution has several distinct advantages over the initial image based approach:
- the image scales better with the page size
- the chart can be further processed
- simpler to code and maintain in RPE
- greatly improved progress tracking and error information in the RPE console view
The example template and VB Script are available on the RPE devWorks examples wiki page: https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Rational Publishing Engine/page/Examples
NOTE: the VB Script is taken from http://automationlab09.wordpress.com/2010/04/29/how-to-draw-a-chart-in-excel-using-vbscript/ and modified it to fit the process. I do not own the copyright and all the credit goes to the original author.
In terms of implementation the changes are fairly minimal:
- VB Script – the Workbook is embedded in a Word document as an OLE
RPE Console Log for running the example.
Testing the script
As mentioned in the previous article as well you should start by running this script in a command line prompt first. The command line execution is also recommended to test any changes you want to make in the VB Script
c:\>cscript d:\tmp\excelPieChart_OLE.vbs "X" "a|b|c" "1|2|3" "d:\tmp\test.doc" Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. Saving Excel in: C:\Users\IBM_AD~1\AppData\Local\Temp\rad5CB9C.tmp.xlsx Saving Doc in: d:\tmp\test.doc Deleting Excel file All done