Title: Double byte character not appearing properly when Excel file is downloaded
Prem,
 
You might want to verify your code outside of servlets - i.e in a simple java program - and then transfer that logic to the servlets.
 
I don't think there's anything servlet specific in the error that you are seeing.
 
> 1. Generated an excel file in UTF8 converted this file into UnicodeLittle. The double byte characters appear properly in the excel >file.
 
What's the code you used to prove that this works?
 
Narayan

----- Original Message -----
Sent: Monday, September 23, 2002 6:58 AM
Subject: Double byte character not appearing properly when Excel file is d ownloaded

Hi,

Am facing problem displaying double byte character from an excel file in the browser. The following are the steps done,

1. Generated an excel file in UTF8 converted this file into UnicodeLittle. The double byte characters appear properly in the excel file.

2. When I try to download the excel file through a servlet then the characters are not appearing properly.

This program runs in NES/NAS(NES in one machine and NAS in another machine; OS - Solaris)

Please advice what is wrong, and also any round abouts that has to be followed.

The following is the code used to download the file

public class ExcelDownload extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
try
{
String fileName1 = System.getProperty( "GX.path.class" ) +"/xyz/a.csv";

FileInputStream infile = new FileInputStream(new File(fileName1));

Reader r = new BufferedReader(new InputStreamReader(infile,"UnicodeLittle"));

res.setContentType("application/vnd.ms-excel");
PrintWriter out = res.getWriter();
char[] buffer = new char[4096];
int len;
while((len = r.read(buffer)) != -1)
out.write(buffer, 0, len);
out.close();
out.flush();
}//end try
catch(Exception e)
{System.out.println("Error e :"+e);e.printStackTrace();}
}
}

Regards,
Prem

Reply via email to