The moose likes Servlets and the fly likes How to display Japanese characters in excel sheet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display Japanese characters in excel sheet?" Watch "How to display Japanese characters in excel sheet?" New topic

How to display Japanese characters in excel sheet?

Dinesh Ramaswamy

Joined: Oct 05, 2001
Posts: 13
I am currently working in a Japanese project.I am facing some problems in displaying japanese characters in excel sheet in windows NT env (english Version).
I am using servlet and jsp to display the japanese characters in the excel sheet.In the servlet i am setting all the neceseary things for response such as
contentType("application:excel,charset=utf-8") etc...
But i am not getting the japanese characters correctly.Instead i am getting junk characters in the japanese fields.

Kindly suggest me some solutions to solve the above mentioned problem..
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Dinesh,
Please do not post the same topic in multiple forums. I am moving this to the Servlets forum.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
As an experiment, try writing the data as HTML content instead, and see if you can view the characters that way. The basic possibilities are: (a) you haven't read in the data correctly in the first place, (b) something is wrong with how you're sending it, and (c) the Excel application isn't set up to view Japanese chars correctly. By displaying the data in other formats, you can get an idea where the problem is.

"I'm not back." - Bill Harding, Twister
Dinesh Ramaswamy

Joined: Oct 05, 2001
Posts: 13
Hi Jim,
As u told i tried with different type like html and text file.Then also i am getting the same junk format.Actually in the servlet i am diong all this things:
httpservletresponse.setHeader("Content-Disposition", "attachment; filename="+fileName+".html");
httpservletresponse.setHeader("Content-Encoding", "UTF-8");
is it because of that UTF-8,i tried to set the encoding as UTF-16.But it giving some run time error stating that
Internal error: exception thrown from the servlet service function (uri=/gehfs/reports/ReportServlet): UTF-16, stack: UTF-16
at com.netscape.server.http.servlet.NSServletResponse.getWriter(
at gehfs.reports.action.HFSReportAction.generateReportForDownload(, Compiled Code)
at gehfs.reports.action.HFSReportAction.executeBusinessMethod(
at gehfs.reports.controller.HFSReportServlet.doPost(, Compiled Code)
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at com.netscape.server.http.servlet.NSServletRunner.Service(
, root cause:

Please help me out in sorting thse problem.
Bhushan Jawle
Ranch Hand

Joined: Nov 22, 2001
Posts: 249
Set content type to "Shift_JIS", that should do the job
I agree. Here's the link:
subject: How to display Japanese characters in excel sheet?
jQuery in Action, 3rd edition