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)
Change of layout in beforeRender event
dzish
<p>Hi,</p>
<p> </p>
<p>I have upgraded BIRT from 4.2.2 to 4.5 and have problem with Excel export.</p>
<p> </p>
<p>When I have many rows new sheet is made. I read I had to change layout from "fixed" to "auto". When I change this layout in designer it looks fine but when I try to change layout programatically in beforeRender event it does not work. I added example report with text items of export type and layout preferences. They have right value after event but report looks like with fixed layout, in xls and even in html (in html 3 pages, in xls 3 sheets).</p>
<p> </p>
<p>Can you help me how to force BIRT for real change of layout?</p>
Find more posts tagged with
Comments
sureshpulapalli
<p>Please attach sample report if you have any.</p>
<p> </p>
<p>It depends, how you are running and exporting the report output.</p>
<p> </p>
<p>Put the script in initialize method, If you are executing the report in viewer and then exporting the report into excel.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Regards,</p>
<p>Suresh</p>
dzish
<p>Oh, sorry. I attached one file but there are two steps for attaching. there is table and report.onRender event skript</p>
Matthew L.
<p>Per your example, I modified the existing code and moved it into the onPrepare method of the report.</p>
<p>This method works for the OpenSource version of BIRT only (will not work in BIRT Pro).</p>
<p>Hopefully this modification works for you.</p>
<p> </p>
<p>Modified Code in onPrepare:</p>
<pre class="_prettyXprint _lang-js">
var outputFormat = reportContext.getHttpServletRequest().getAttribute("attributeBean").format;
if("xls,xlsx,html".indexOf(outputFormat) > -1){
reportContext.getDesignHandle().layoutPreference = "auto layout";
}
</pre>
dzish
<blockquote class="ipsBlockquote" data-author="Matthew L." data-cid="144361" data-time="1466516470">
<div>
<p> </p>
<p>Per your example, I modified the existing code and moved it into the onPrepare method of the report.</p>
<p>This method works for the OpenSource version of BIRT only (will not work in BIRT Pro).</p>
<p>Hopefully this modification works for you.</p>
<p> </p>
<p>Modified Code in onPrepare:</p>
<pre class="_prettyXprint _lang-js">
var outputFormat = reportContext.getHttpServletRequest().getAttribute("attributeBean").format;
if("xls,xlsx,html".indexOf(outputFormat) > -1){
reportContext.getDesignHandle().layoutPreference = "auto layout";
}
</pre>
</div>
</blockquote>
<p>Yes, it works! Thank you. I haven't thought about that event - onPrepare.</p>