JXL generate excel spreadsheet with decimal value in the Brazilian standard

Asked

Viewed 112 times

0

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

tabela gerada com o jxl

Note that the values of the two columns are generated in the American standard with a decimal point instead of a comma. This way when the user will take advantage of the spreadsheet to create a formula and add the values excel does not accept, because this standard number formatting is not BR.

I tried to format the values for the BR standard using the Numberformat class see: Planilha com valores formatados

Only I don’t know why the hell when printing the number jxl puts ' before the number. This keeps preventing the user from creating a formula to add cells, because as it has this ' before the number excel sees it as String and does not sum. See in the image below the ' that is printed before the number:

Apóstrofe sendo imprimida antes do valor formatado

Has anyone been there? How can I print the value in the BR standard so that the user who generated the spreadsheet can create formulas to add cells? Thank you!

1 answer

0


I managed to fix it. I will post the solution in case someone finds the same problem:

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

planilha.addCell(new Number(col++, row, ((Double) item).doubleValue(), numberFormat));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.