JXL generate excel sheet with decimal value in Brazilian standard

0

I'm using Java and Jsf on my system and there's a screen where you have the option to generate an excel spreadsheet. The generation of the worksheet is ok. The problem I'm encountering is in columns that have numeric values of type Double. For example:

NoticethatthevaluesofthetwocolumnsaregeneratedintheAmericanstandardwithadecimalpointinsteadofacomma.Thiswaywhentheuserisgoingtotakeadvantageoftheworksheettocreateaformulaandaddthevaluesexceldoesnotaccept,sincethisnumberformattingpatternisnottheBR.

ItriedtoformatthevaluesfortheBRstandardusingtheNumberFormatclasssee:

Ijustdonotknowwhytheheckwhenprintingthenumberthejxlputs'beforethenumber.Thiscontinuestopreventtheuserfromcreatingaformulatoaddthecells,becauseasithas'beforethenumberexcelseesitasStringandnotsum.Seeintheimagebelowthe'whichisprintedbeforethenumber:

Has anyone ever gone through this? How can I print the value in the BR standard so that the user who generated the worksheet can create formulas to add the cells? Thanks!

    
asked by anonymous 26.10.2018 / 19:16

1 answer

0

I managed to resolve. I'll post the solution in case someone encounters the same problem:

NumberFormat decimalNo = new NumberFormat("#,##0.00");
WritableCellFormat numberFormat = new WritableCellFormat(decimalNo);

planilha.addCell(new Number(col++, row, ((Double) item).doubleValue(), numberFormat));
    
26.10.2018 / 21:37