Home
Analytics
How to create and add a new NumberFormatter by java developping
cocou
<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
Clement Wong
<p>Are you able to test the JAR in the report design in the Designer by manually adding it into a sample report design? If that works, then you can add the JAR into the report design dynamically.</p>
<p> </p>
<p>Here's code that adds the JAR into the design's Resources > Jar Files via the Design Engine API.</p>
<p> </p>
<p><a data-ipb='nomediaparse' href='
https://github.com/eclipse/birt/blob/bab46c1570900bf70d4ab750c8be3cc344553882/testsuites/org.eclipse.birt.report.tests.model/src/org/eclipse/birt/report/tests/model/regression/Regression_150687.java'>https://github.com/eclipse/birt/blob/bab46c1570900bf70d4ab750c8be3cc344553882/testsuites/org.eclipse.birt.report.tests.model/src/org/eclipse/birt/report/tests/model/regression/Regression_150687.java</a></p>
;