Forum Moderators: open

Message Too Old, No Replies

Export chinese char to exl using ExcelCSVPrinter in the csv file

Unable to see the chinese characters after export the xsl file,

         

Thendral

12:40 pm on Jan 29, 2010 (gmt 0)

10+ Year Member



Hi,

Our application using in English, German, Franch and chinese.
String chineseCharacter=""; // chineseCharacter like <Chinese KW 1>. 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 <Chinese KW 1>;

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: bill at 11:43 pm (utc) on Jan. 29, 2010]
[edit reason] replaced unicode characters with <Chinese KW 1> [/edit]

bill

11:33 pm on Jan 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld Thendral. Sorry, but this forum doesn't handle Unicode...yet. I hear it's in the works.

Could you clarify your question a bit more? Is this an Excel problem or something on the database side?

Thendral

6:45 am on Jan 30, 2010 (gmt 0)

10+ Year Member



bill,

1. I am java developer. Our app developing in java application using struts, ejb. server jboss 4 and jdk1.5. Our application was running the english, german and french. Now we added the chinese also.

2. We saved chinese data(like some chinese characters) to the oracle database. When we need data, we will export the data to excel sheet and shows all the detail.

3. The german and french letter displaying correctly. But the chinese only not showing the original (like some chinese characters). Its show some jung characters not in original. Already We using the ExcelCSVPrinter to export the data. Its working the Eng, German and French also.

//Here, i unable to show the chinese chars to you.

This is my code part.

String chineseCharacter= " some chinese characters"; // This chinese stored in database.
BufferedWriter printer = new BufferedWriter(new OutputStreamWriter(responses.getOutputStream(),"cp1252"));
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();

When i trying to see this in browser its shows correctly.
This code :
responses.setContentType("text/html"); // its shows correctly all chinese and other language chars.

But i tried to export this in my through browser inline opening doesn't shows.
This part code :
responses.setContentType("application/download;charset=UTF-8");

Expectation :
------------
After export the data want to show the original chinese characters in excel file. we stored csv file.

kinldy help me.

Regards
Palani

    bill

    4:22 am on Jan 31, 2010 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



    I'm not a Java developer, so I can't help you there. Are you inputting and outputting everything in the same character set? You're not mixing encoding are you?