iReport对csv格式报表的中文支持(顶着有分)

lanpa007 2006-03-20 04:39:37
近期由于项目使用iReport和jasperReport开发报表,本人下载了一个iReport-1.1.0的开发包,试用了一把,发现这个开发包对纯文本格式的中文报表格式支持极为不好,举个简单的例子:新建一个报表模板,就在title部位添加一个static text,里面随便写上两个汉字,把属性页中的诸如pdf font name等属性修改好,保存为demo.jrxml-->编译--->设置预览格式为csv预览或者纯文本预览,-->到保存模板目录下查看输出的报表,打开demo.csv或demo.txt,发现只有乱码存在。

有解决过此类问题的兄弟,谢谢给个解决方案,分数不够,我再开帖送上。
帮忙顶的兄弟,人人有分。
如果有对iReport+jasperReport熟悉的高手在此地讨论,兄弟会非常荣幸。
...全文
484 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
lanpa007 2006-05-22
  • 打赏
  • 举报
回复
结贴时漏了egg13(13er),下次再开帖时补给您
lanpa007 2006-05-22
  • 打赏
  • 举报
回复
先结贴再说,以后改了源代码再贴出结果
hackangcn 2006-04-12
  • 打赏
  • 举报
回复
to hackangcn(龙卷风) ;
特别感谢,我先试试您的方法。
如果我在iReport中对这个问题实在搞不定而客户又坚决要求csv格式的报表,我就采用您的建议。
对帮顶的兄弟,也给予感谢,等我解决了这个问题,马上结贴。

。。。。。。。。。。。。。。
我帮你,你帮我,这样大家才能都提高
egg13 2006-04-12
  • 打赏
  • 举报
回复
- -||
我还自己去写了生成CSV的bean
jy03108434 2006-04-12
  • 打赏
  • 举报
回复
顶者有分~
lanpa007 2006-04-12
  • 打赏
  • 举报
回复
to楼上:兄弟,要试试再给我这么说吧,这些东西我都设过了,没有效果的。反正现在这个需求不急,等我忙完这段时间,把iReport的源码看一下。
大枫树林 2006-04-11
  • 打赏
  • 举报
回复
每一个显示要字体为宋体,misong,chinese simpliate
就行了
lanpa007 2006-04-10
  • 打赏
  • 举报
回复
to hackangcn(龙卷风) ;
特别感谢,我先试试您的方法。
如果我在iReport中对这个问题实在搞不定而客户又坚决要求csv格式的报表,我就采用您的建议。
对帮顶的兄弟,也给予感谢,等我解决了这个问题,马上结贴。
hackangcn 2006-04-08
  • 打赏
  • 举报
回复
web.common.sn等等这些都是你在资源文件里面定义的

如:web.common.sn=序号
employee.dept=部门

SpHib 2006-04-08
  • 打赏
  • 举报
回复
照你说的做了一个,中文显示为?号。其他 字符正常,
不会解决,帮你顶一下
常遇道 2006-04-08
  • 打赏
  • 举报
回复
up
hackangcn 2006-04-07
  • 打赏
  • 举报
回复
csv格式导出很方便的,直接一个方法就可以

我发一个你参考参考

public void toCsv(
ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws Exception {


String fileName="employee_export.csv";
httpServletResponse.setContentType( "application/file");
httpServletResponse.setHeader("Content-disposition",
"attachment; filename=" + fileName );
MessageResources messageResources=getResources(httpServletRequest);

try{

StringBuffer content=new StringBuffer();
content.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.label"))
.append('\n')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"web.common.sn"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.zgxm"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.dept"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.qx"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.yhm"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.qzwjm"))
.append(',')
.append(messageResources.getMessage(this.getLocale(httpServletRequest),"employee.py"));


List employeeList=this.getCommonFacade().findByCriteria(DetachedCriteria.forClass(TbEmployee.class).setFetchMode(TbEmployee.PROP_BM_ID,FetchMode.JOIN));
int i = 1;

for (Iterator it =employeeList.iterator();it.hasNext();){
TbEmployee employee=(TbEmployee)it.next();

content.append('\n')
.append(i).append(',')
.append(employee.getZgxm()).append(',')
.append(employee.getBmId().getBmmc()).append(',')
.append(StringUtil.getStrValue(employee.getQx())).append(',')
.append(StringUtil.getStrValue(employee.getYhm())).append(',')
.append(StringUtil.getStrValue(employee.getQzwjm())).append(',')
.append(StringUtil.getStrValue(employee.getPy())).append(',');
i++;
}
OutputStream bos = httpServletResponse.getOutputStream();
byte[] buff = content.toString().getBytes();
bos.write(buff);
bos.flush();
bos.close();
}catch(Exception e){
e.printStackTrace();
}
} // end downLoad
lilijr 2006-03-23
  • 打赏
  • 举报
回复
字符集的问题,有些字体是不能用的
lanpa007 2006-03-23
  • 打赏
  • 举报
回复
下载AsiaText后,pdf格式、xls格式、html格式都没有问题,偏偏这类纯文本格式的就会出乱码,怪!
lanpa007 2006-03-23
  • 打赏
  • 举报
回复
楼上,那如果我想生成csv格式的报表,里面又有中文,有没有好的办法解决。您以前导出过csv这类格式的报表吗?
liqdok 2006-03-22
  • 打赏
  • 举报
回复
星空报表
http://download.enet.com.cn/html/030212006012001.html
优点:
功能比较全面,可以作为独立的报表服务器使用,也可以内嵌到其他web应用中,输出格式包括pdf、excel、rtf等,支持任务订制、历史报表存储、在线自定义报表(WEB创作)等。
缺点:
免费使用
挑大梁 2006-03-22
  • 打赏
  • 举报
回复
还是字符集有问题

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧