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)
Birt String Justification row-by row in excel report.
Bhumi U.
Hi.
I have to generate the excel report .where one column is specified as String data type and that column has both String/Number value.Now I want string value in that column to be justifield on left andnumber value is justified as right in that column.. I mean Mixed Justification( Left/Right) for one column. I tried some alternate approach but it doesn't work. Can you please suggest some solution?
Find more posts tagged with
Comments
mwilliams
Try this in your data element's onCreate script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (isNaN(this.getValue())){
this.getStyle().textAlign = "left";
}
else{
this.getStyle().textAlign = "right";
}
</pre>
Yaytay
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="110065" data-time="1349193974" data-date="02 October 2012 - 09:06 AM"><p>
Try this in your data element's onCreate script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (isNaN(this.getValue())){
this.getStyle().textAlign = "left";
}
else{
this.getStyle().textAlign = "right";
}
</pre></p></blockquote>
<br />
This should work (If it doesn't try it in onRender), but it doesn't solve the cause of the problem, which is that Excel thinks that all your values are text.<br />
In general, this really limits the usefulness of a spreadsheet report, because the recipient can't do any further analysis on your data.<br />
I hope that, in your case, that's not a problem, because I can't think of a simple fix for it!<br />
The standard approach would be to have one column for the text and another for the numbers, but that's not your requirement.<br />
You could try having two data controls in the cell, one string and one number, and then dynamically swap between them at runtime - i.e. in the 'if' statement above make one of the controls invisible.<br />
You will also have to jump through some hoops to get BIRT to treat the same field as string in one control and number in another (probably simplest to add another column to your data set that is of a numerical type and do the conversion there).<br />
<br />
Jim
Bhumi U.
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="110065" data-time="1349193974" data-date="02 October 2012 - 09:06 AM"><p>
Try this in your data element's onCreate script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (isNaN(this.getValue())){
this.getStyle().textAlign = "left";
}
else{
this.getStyle().textAlign = "right";
}
</pre></p></blockquote>
<br />
<br />
<br />
Hi Mike, <br />
I tried this approach and it worked for my issue. Thanks for your suggestion. It really helped.
mwilliams
You're welcome! Let us know, whenever you have questions!