格式是UTF-8,
用editplus打開正常,但是excel打開就是亂碼了!!
怎么解決?
- Java code
os = response.getOutputStream(); String title = "發送編號,時間,標題,接收號碼,訊息編號,接收時間,接收狀態"+"\r\n"; os.write(title.getBytes("UTF-8")); QueryBean qb = (QueryBean) request .getAttribute(GlobalConstNaming.QUERY_BEAN_NAME); ResultBean resultBean = null; resultBean=statReportMag.thrdinfo(qb,jobid,date); List result = (List)resultBean.getTotalResult(); for(int i=0;i<result.size();i++) { StatSendthrdbean bean = (StatSendthrdbean)result.get(i); String s = bean.getJobid(); s = s + ","; s = s + bean.getDate(); s = s + ","; s = s + (bean.getContent()==null?" ":bean.getContent()); s = s + ","; s = s + (bean.getRecvmobile()==null? " " : bean.getRecvmobile()); s = s + ","; s = s + (bean.getMsgid()==null ? " " : bean.getMsgid()); s = s + ","; s = s + (bean.getRecvdate()==null? " " : bean.getRecvdate()); s = s + ","; s = s + (bean.getStatus()==null ? " " : bean.getStatus()); s = s + "\r\n"; os.write(s.getBytes("UTF-8")); }
鐧奸?佺法铏?鏅傞枔 鍏у? 鎺ユ敹铏熺⒓ 瑷婃伅绶ㄨ櫉 鎺ユ敹鏅傞枔 鎺ユ敹鐙?鎱?
114 2008-6-5 10:31 cytest0605001 920130077 2008-6-5 16:31 鏈?櫦閫?
114 2008-6-5 10:31 cytest0605001 920130088 2008-6-5 16:31 鏈?櫦閫?
114 2008-6-5 10:31 cytest0605001 920130066 2008-6-5 16:31 鏈?櫦閫?
------解决方案--------------------
这种情况的话,有可能是你保存的UTF不一定是EXCEL所知道的UTF-8文件的Unicode签名BOM(Byte Order Mark)。
UTF文件在前三个字节(EF BB BF)可以用作标记的,而且好像是分big endian 和 small endian,而且有时是可以没有这个标记,
你这里可能是导出的时候没有这三个字节标识的,所以excel可能因此而不认识是用utf-8标识的
关于UTF-8文件标识字节的介绍,你可以参考这篇文章
http://hi.baidu.com/kittig/blog/item/39d8b48f514262eff01f367b.html
------解决方案--------------------
dui
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
up
------解决方案--------------------
帮顶