In my java class I am exporting some records to xls file using table tag which contains hindi charcters and the problem is that the hindi characters are not encoded in excel sheet(Libreoffice calc) and giving garbage value as आननà¥ヘद विहार instead of hindi characters.
I searched for this a lot and from other forums I solved my problem of java class but encoding into xls file is not getting
solved.
The records using table tag which is sent to excel method is::
table = table <tr>
<td> masterList.get(j).getBus_stop_cd() </td>
<td> masterList.get(j).getBus_stop_nm()</td>
<td>masterList.get(j).getDevnagiri_nm() </td>
<td>masterList.get(j).getBus_stop_address() </td>
masterList.get(j).getGlobal_short_cd()</td></tr>
table = table + "</table>";
session.setAttribute("abc", table);
In this entire data of <table> tag is sent to dispexcel method through setting into session i.e using this 'session.setAttribute("abc", table) and the Devnagiri_nm which is iterated from list contains the hindi characters.
The method use for exporting to excel is:
public ActionForward dispExcel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
String fileType = "xls";
String filename = (String) session.getAttribute("filename");
response.setContentType("application/vnd.ms-excel; charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "." + fileType + "\"");
PrintWriter out2 = response.getWriter();
String n = (String) session.getAttribute("abc");
out2.print(n);
out2.flush();
out2.close();
return null;
}
Can anyone will tell me how to solve this problem?