Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Element "report.Body[0]" is not allowed to be added into the (Body) of "Report Design
wiscdev
<p>Nevermind. I discovered that the error was because I attempted to add the same element twice. From reading the error I thought that it meant that I could not have 2 grid children of body, which contradicted several code samples I had found.</p><p> </p><p> </p><p>---</p><p> </p><p>Hello,</p><p> </p><p>I'm attempting to open a .rpt file with an empty body, dynamically add some grids to it, and generate a PDF.</p><p> </p><p>The core of my code looks like the following, where getItemGrid() is a private method that returns a GridHandle to a grid already created. It seems to fail at the designHandle.getBody().add(grid); line, with the following error:</p><p> </p><div>org.eclipse.birt.report.model.api.command.ContentException: Element "report.Body[0]" is not allowed to be added into the (Body) of "Report Design", for it is already in the design tree.</div><div>at org.eclipse.birt.report.model.util.ContentExceptionFactory.createContentException(ContentExceptionFactory.java:43)</div><p> </p><p>(rest of stack trace omitted.)</p><p> </p><p>Could tell me if this code is salvagable? Thanks. Usually I think of "Add" as meaning "Append." I need to add multiple grids to the body of this report.</p><div><pre class="_prettyXprint">IReportRunnable design = null;design = engine.openReportDesign(templateFilename); ReportDesignHandle designHandle = (ReportDesignHandle) design.getDesignHandle( );ElementFactory designFactory = designHandle.getElementFactory();for (int i = 0; i < itemNumbers.size(); i++) { GridHandle grid = getItemGrid(designFactory, designHandle, itemNumbers.get(i), itemSizes.get(itemNumbers.get(i))); designHandle.getBody().add(grid);}IRunAndRenderTask task = engine.createRunAndRenderTask(design); File file;file = new File(outputFileName);FileOutputStream fop = new FileOutputStream(file);PDFRenderOption pdfOptions = new PDFRenderOption();pdfOptions.setOutputFormat(DOCUMENT_FORMAT);pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW,IPDFRenderOption.FIT_TO_PAGE_SIZE);pdfOptions.setOutputStream(fop);task.setRenderOption(pdfOptions);task.run();task.close();</pre></div>
Find more posts tagged with
Comments
wiscdev
<p><deleted></p>
mwilliams
<p>So, this issue is solved?</p>