首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

用jxl读excel中文乱码,从iso8859-1到gb2312,gbk,utf-8转换均无效,

2012-01-19 
用jxl读excel中文乱码,从iso8859-1到gb2312,gbk,utf-8转换均无效,在线等...如题jdk版本:j2sdk1.4.2_12;操

用jxl读excel中文乱码,从iso8859-1到gb2312,gbk,utf-8转换均无效,在线等...
如题
jdk版本:j2sdk1.4.2_12;
操作过程:本地上传excel到服务器,之后,读excel部分字段到数据库,结果,非中文正常,中文乱码。
部分代码:Cell   cell   =   rs.getCell(j,i);
  String   s1=cell.getContents();
                    s1中文乱码;
                    将s1用以下方式转换,乱码;
                    String   s2=new   String(s1.getBytes( "ISO8859_1 "));
String   s2=new   String(s1.getBytes( "gb2312 "));
String   s2=new   String(s1.getBytes( "utf-8 "));
String   s2=new   String(s1.getBytes( "gbk "));
以上做法我是想看看目前的编码,失败;
之后进行转换,从iso8859-1到   gb2312等,互相转换,还是乱码!!!!
请高人指点,谢谢....

[解决办法]
request.setCharacterEncoding( "GBK ");//这样应该可以。。。
Cell cell = rs.getCell(j,i);
String s1=cell.getContents();
System.out.prinltn(s1);

热点排行