Jump to content
We've recently updated our Privacy Statement, available here ×

Locale not considered when exporting to Excel


ktrinad

Recommended Posts

By: josep - josepse

Locale not considered when exporting to Excel

2004-05-13 00:48

Hi,

 

When exporting a number to Excel the code expects the "." as a decimal separator and doesn't treat de grouping separator.

 

My locale has "," as decimal separator and "." as grouping separator. Here is a possible modification to update this bug:

 

protected void exportText(JRPrintText text, JRExporterGridCell gridCell, int x, int y)

{

....

if (isAutoDetectCellType)

{

try

{

java.text.DecimalFormat dec = new java.text.DecimalFormat();

java.text.ParsePosition pos = new java.text.ParsePosition(0);

Number num = dec.parse(text.getText().trim(), pos);

if (pos.getIndex() != text.getText().trim().length())

cell.setCellValue(text.getText());

else

cell.setCellValue(num.doubleValue());

}

catch(Exception e)

{

cell.setCellValue(text.getText());

}

}

...

}

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...