Problem
“I have nearly 500 reports, each report having logo on the right up corner in all tabs, in a cell having formula “boimg://logo.bmp” and read as image URL. Now i have come up with change in logo format. Now the same formula is to be changed to “boimg://logo.jpg””.
Code
private static int replaceExpression(DocumentInstance widoc, String from, String to) { ReportDictionary reportDictionary = widoc.getDictionary(); ArrayList nodes = getListOfTreeNodes(widoc.getStructure(), false); int n = 0; for (TreeNode node : nodes) { if (node instanceof ReportCell) { ReportCell reportCell = (ReportCell)node; ReportExpression reportExpression = reportCell.getExpr(); if (reportExpression instanceof FormulaExpression) { FormulaExpression formulaExpression = (FormulaExpression)reportExpression; if (formulaExpression.getValue().compareTo(from) == 0){ FormulaExpression newFormulaExpression = reportDictionary.createFormula(to); reportCell.setExpr(newFormulaExpression); n += 1; } } } } widoc.applyFormat(); return n; } public static ArrayList getListOfTreeNodes(TreeNode root, boolean onlyLeaves) { ArrayList nodes = new ArrayList(); treeNodeTraversal(root, nodes, onlyLeaves); return nodes; } private static void treeNodeTraversal(TreeNode node, ArrayList nodes, boolean onlyLeaves) { if (!onlyLeaves || node.isLeaf()) { nodes.add(node); } for (int i = 0; i < node.getChildCount(); ++i) { treeNodeTraversal(node.getChildAt(i), nodes, onlyLeaves); } }
Hi,
Thanks a lot…. nice piece of code.. very helpful..
Regards,
Raghu
LikeLike
Does it work under 4.x.? I receive the error “This feature is not implemented. (Error: RWI 00013)” at webidoc.getStructure();
Regards,
Sorin
LikeLike
I cannot say that 4.x is developer friendly…
You cannot do that using 4.x public SDK. The only thing that works from Report Engine SDK is report running workflow.
LikeLike
Hmm, sounds like the 4.x SDK is much more limited that it’s predecessors – in what ways?
LikeLike
Sorry it was old comment. 4.1 SDK is very promising. But it is completely new and based on RESTful webservices. (I have not tried it yet though)
LikeLike
No problem 🙂 – I’m just trying to figure out why going from 3.x to 4.1 is so problematic. I’m guessing part of it is that it looks like SAP changed their approach to implementing some features.
LikeLike