请高手赐教!用poi包向Excel里写数据时遇到中文出现乱码。 本人是将mysql中的数据导入到excel中,可惜总是出乱码!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mysql 不支持 unicode,所以比较麻烦。将 connectionString 设置成 encoding 为 gb2312String connectionString = "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gb2312";测试代码: String str = "汉字"; PreparedStatement pStmt = conn.prepareStatement("INSERT INTO test VALUES (?)"; pStmt.setString(1,str); pStmt.executeUpdate();数据库表格: create table test ( name char(10)////////////////////////////////////////str = new String(str.getBytes("ISO8859_1","gb2312")) 将需要写中文的单元格设置为:cell.setEncoding(HSSFCell.ENCODING_UTF_16); 我使用的是sql2000,这样导入没有问题。 怎么用正则表达式把路径中的反斜杠换掉 是不是.replace("\n","<br>")出错了? CommonTemplate发布0.8.7版本 很郁闷的错!大家帮忙看看吧! 大虾们请指点一下在JAVA中如何实现类似于VB的选项卡啊 “无法显示网页”的问题? 请教大家一个关于 windows 和 linux 下的中文问题? 求救....学习时间上的矛盾 J2EE中有哪些框架类型? 严重: Exception starting filter struts2 如何让JTable中的某一行处于选中状态? JBuilder问题,高分给!!!
将 connectionString 设置成 encoding 为 gb2312
String connectionString
= "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gb2312";测试代码:
String str = "汉字";
PreparedStatement pStmt = conn.prepareStatement("INSERT INTO test VALUES (?)";
pStmt.setString(1,str);
pStmt.executeUpdate();数据库表格:
create table test (
name char(10)
////////////////////////////////////////
str = new String(str.getBytes("ISO8859_1","gb2312"))
cell.setEncoding(HSSFCell.ENCODING_UTF_16);