2

I am trying to generate a CSV file in my application using the code below:

If I open the file in Excel 2007, then I get £ wherever a £ sign should appear.

try {
FileWriter fw = new FileWriter(filename);

 fw.append("Item Name");
fw.append(',');

fw.append("Item Sku");
fw.append(',');

fw.append("Tax Rate (%)");
fw.append(',');

fw.append("Item Qty");
fw.append(',');

fw.append("Unit Price (\u20AC)");
fw.append(',');

fw.append("Total Price (\u20AC)");
fw.append(',');

fw.close();
}
catch (Exception e) {
 Log.e(getClass().getSimpleName() ,"Error in create CSV File: "+e.getMessage())
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Dhaval Jivani
  • 9,467
  • 2
  • 48
  • 42
  • 1
    Do you have any solution? if you have then add your answer please. I have same issue with euro sign. thanks in advance. – rockstar Dec 11 '16 at 09:27
  • 1
    I had same issue in my nodejs app, You may need to use the `"\t"` delimeter, and preappend BOM `'\ufeff'` in your csv string and set the encoding to `'utf16le'` just like I did here: https://stackoverflow.com/a/45232685/5228251 I don't have idea of java so you need to look into how to do this in java. hope this helps – narainsagar Jul 21 '17 at 11:23

1 Answers1

-1

You need to use windows-1252 encoding and not the default. This worked for me.

Djalas
  • 1,031
  • 9
  • 6