Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Export the chinese character in excel using java

807580Dec 22 2009 — edited Feb 23 2010
Hi,

Our application using in English, German, Franch and chinese.
String chineseCharacter=""; // chineseCharacter like 長长牀床東东彿佛. This chinese data coming from oracle database..

My code
------------

BufferedWriter printer = new BufferedWriter(new OutputStreamWriter(responses.getOutputStream(),"utf-8"));
responses.setContentType("application/download");
responses.setHeader("Cache-Control", "cache");
responses.setHeader("pragma", "cache");

ExcelCSVPrinter outcr = new ExcelCSVPrinter(printer);

String displayname="ChineseReport.csv";
responses.setHeader("Content-Disposition","inline; filename=\"" + displayname + "\"");
outcr.write("Report Header Name");
outcr.writeln();
outcr.write(chineseCharacter);
outcr.writeln();

After export the data to excel show the result for 長长牀床東东彿佛. But not show the original result 長长牀床東东彿佛

I use the following stmt
responses.setContentType("text/html charset=UTF-8");
Its shows the correct result for chinese character.

I use the below statement
responses.setContentType("application/download; charset=UTF-8");
or
responses.setContentType("application/vnd.ms-excelset;charset=UTF-8");
or
responses.setContentType("application/vnd.ms-excel;charset=UTF-8");

The out put show the in the excel sheet ???????? or some other jung characters.
What can i do here?. After export,I want to show the original chinese character in the excel sheet using the ExcelCSVPrinter.

Thanks & Regards
Thendral

Edited by: palanithendral on Dec 24, 2009 5:14 AM

Edited by: palanithendral on Dec 29, 2009 11:41 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2010
Added on Dec 22 2009
7 comments
4,843 views