Home
Developing Analytics Applications
How to create and add a new NumberFormatter by java developping
Migrateduser
<p>Hello,</p>
<p>i would like to create my own NumberFormatter and use it to format my data. </p>
<p>This Formatter wil translate number in letter (in french) so the needing code is like this </p>
<p> </p>
<p> </p>
<p> </p>
<div>
<blockquote class="ipsBlockquote">
<div>private String getMontantLettre(Number value) {</div>
<div>NumberFormat nombreEnLettreFormat = new RuleBasedNumberFormat(Locale.FRANCE, RuleBasedNumberFormat.SPELLOUT);</div>
<div>int partieEntiere = value.intValue();</div>
<div>int partieDecimale= new Double(((value.doubleValue() - partieEntiere) *100)).intValue();</div>
<div> </div>
<div>String montantLettre = nombreEnLettreFormat.format(partieEntiere) + " euros " + (partieDecimale>0 ? nombreEnLettreFormat.format(partieDecimale) + (partieDecimale>1? " cents " : "cent") :"");</div>
<div>return montantLettre;</div>
<div>}</div>
<p> </p>
</blockquote>
<p> </p>
</div>
<div> </div>
<div> </div>
<div> </div>
<div>but i did'nt know how integrate it in my birt code using the </div>
BIRT Design Engine API
<div> </div>
<div> </div>
<div>
<div>
<blockquote class="ipsBlockquote">
<div>ComputedColumn computedComponent = StructureFactory.createComputedColumn();</div>
<div>PropertyHandle boundCols = chequeInfoGrid.getColumnBindings();</div>
<div>computedComponent.setName("mnt_sol_reg_fac"); </div>
<div>computedComponent.setExpression("dataSetRow[\"mnt_sol_reg_fac\"]");</div>
<div>boundCols.addItem(computedComponent);</div>
<div>DataItemHandle data = factory.newDataItem(null);</div>
<div>data.setResultSetColumn("mnt_sol_reg_fac");</div>
<div>cell.getContent().add(data);</div>
<div>cell.getPrivateStyle().setNumberFormat("#,##0.00 €");</div>
<div>cell.getPrivateStyle().setNumberFormatCategory(DesignChoiceConstants.NUMBER_FORMAT_TYPE_CURRENCY);</div>
<div>cell.setProperty(StyleHandle.PADDING_TOP_PROP, "5mm");</div>
<p> </p>
</blockquote>
<p> </p>
</div>
</div>
<div> </div>
<div> </div>
<div> </div>
Find more posts tagged with
Comments
There are no comments yet