File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes $ symbol not displayed properly in excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "$ symbol not displayed properly in excel" Watch "$ symbol not displayed properly in excel" New topic
Author

$ symbol not displayed properly in excel

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
I am using POI API to generate an Excel file from java. But, $ symbol is replaced by a weired character in the cells.

What shall be the reason behind it?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41116
    
  45
I don't notice problems with having a $ character in a string field. What code are you using to create the file? Post a SSCCE.


Ping & DNS - my free Android networking tools app
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
I would like to inform you that $ symbol is displayed properly on my local machine. but, the same code is deployed in the production environment and there its showing weird symbol �.

i did some research on this symbol and found out that this symbol denote a currency when the symbol for a particular currency is unavailable.

then i go through the source code and found out the below lines of code:

NumberFormat formatter = NumberFormat.getCurrencyInstance();
cell.setCellValue(formatter.format(cost));

This number format returns a currency format for the current default locale. So, i guess, the locale setting for currency in the production environment is changed.

But, i dont have access to production environment. So, my manager has asked me to replicate this issue on my local system by changing the locale setting of windows xp.

i go to control panel -> Regional and Language Options. In the Regional Options tab, i click on customize button and Customize Regional Options dialog box opens. In the Currency tab of this dialog box, i changed the currency symbol to �. And then save the changes.

Then i restart the machine and start our project server. But, on my local machine its still displaying the $ symbol in the excel file. i am not able to replicate the issue.

Please guide me friend to resolve this issue.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41116
    
  45
So the issue is not about the "$"not being displayed properly, but about NumberFormat.getCurrencyInstance returning something other than what was expected.

In that case I'd use NumberFormat.getCurrencyInstance(Locale) to request the currency symbol of whatever locale is being used.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
Yes Ulf, we can use NumberFormat.getCurrencyInstance(Locale.US) to request the $ currency symbol.

but, the problem is i can't change code in the production environment and test it there directly. so, i need to replicate the issue on local system. for that, i tried the steps mentioned in my previous post. but it doesn't work.

please help me out.

Note: at the start of this topic, i asked a problem, for which we have a solution now. but the problem is only after i replicate the issue on my local machine, my manager will approve my changes to the production.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41116
    
  45
For these purposes one needs a machine that mimics the production machine in every aspect. That should be part of the development/testing pipeline anyway. Developer's machines are never the same as production machines to begin with, so what does or does not happen on them is of little consequence.

What's important is that you know what the problem is, and that your code change fixes it. If your manager then doesn't approve it, and won't get you a replica of the server machine for testing, that's his problem; your work is done.
 
 
subject: $ symbol not displayed properly in excel
 
Similar Threads
what is this symbol "[$-409]dd-mmm-yy;@ " Excel to Java???
WA #1.....word association
How to fix blue triangle in top left corner of cell in excel while creating using apache poi 3.6
Export to excel in jsp
how to write and read excel file