aspose file tools
The moose likes Servlets and the fly likes Need help for downloading .xls or .csv file having special character Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Need help for downloading .xls or .csv file having special character" Watch "Need help for downloading .xls or .csv file having special character" New topic
Author

Need help for downloading .xls or .csv file having special character

Abhishek Purwar
Ranch Hand

Joined: Dec 15, 2007
Posts: 62

Hi all,

I have one problem.

I am writing data in response output stream and then set header as "content-disposition" : "attachment.filename=" + <filename>.

I have given file name having extension as xls or cvs because i want the content to be in this format file.

How should i set character encoding for file because data have some special character and so file shows different character in windows and different in linux???

Kindly provide me some solution.

Thanks to everyone for their suggestion.


Abhishek Purwar,
Bangalore.
Abhishek Purwar
Ranch Hand

Joined: Dec 15, 2007
Posts: 62

I have fixed this issue.

Solution :

Need to set the charset for response output stream.

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out,"ISO-8859-1"));

where out is response output stream.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You can also try to set this for a Excel document:

and when it is a CSV document - this one:

The data you are writing to the output stream, does it have the right encoding ??

Normally it would be a byte array you are writing to the output - but if the data in the byte array doesn't have the correct encoding, then you can't do anything about it when you try to serve it.


Regards, Rene Larsen
Dropbox Invite
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Need help for downloading .xls or .csv file having special character
 
Similar Threads
Some Questions |About IO
Wrting Response?
How to view XLS documents loaded from database
Hex character in XML
write data to xls and save this xls at client machine