怎样生成csv文件,求指导。 本帖最后由 qiuqiu_henry 于 2012-12-19 21:55:32 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 大家看我这样写行吗?public void downloadCvs(List<RepairCatalogSearchResultsVO> rowDataList) throws CROSException{ try{ File file = new File("D:/results.csv"); FileOutputStream out = new FileOutputStream(file); OutputStreamWriter osw = new OutputStreamWriter(out); BufferedWriter bw = new BufferedWriter(osw); //insert data bw.write("ATA"); bw.write(","); bw.write("componentDesc"); bw.write(" ") ; bw.newLine(); Iterator<RepairCatalogSearchResultsVO> ite = rowDataList.iterator(); while (ite.hasNext()) { RepairCatalogSearchResultsVO vo = ite.next(); bw.write(vo.getAtaNum()); bw.write(","); bw.write(vo.getComponentDesc()); bw.write(" ") ; bw.newLine(); } //close bw.close(); osw.close(); out.close(); } catch(Exception e){ e.printStackTrace() ; } } 点击下载的时候把这些数据放到输出流中刷出来。就跟普通文件下载没什么区别,只是不用再去读文件而已。具体jsp下载文件网上很多例子,这里就不多说了。搜一下一大堆 struts2和json-default的问题 求excel导入处理页面代码 java中怎么样锁定内存中的对象???在线等 MyFaces中tree2的问题 求webwork高手数组接值问题 (正则表达式)判断一个全英文字符串是否以Info结尾怎么写? 如何静态的下载链接? 不重启JBOSS能干以下些事吗?jboss-3.2.6问题 我的ORACLE怎么连不上,帮忙啊! 小弟求助!谢了! 求助:关于在jdk源码中加入断点报错 求助S2SH应用使用Hibernate的纯SQL多表查询不能返回结果集!
public void downloadCvs(List<RepairCatalogSearchResultsVO> rowDataList) throws CROSException{
try{
File file = new File("D:/results.csv");
FileOutputStream out = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(out);
BufferedWriter bw = new BufferedWriter(osw);
//insert data
bw.write("ATA");
bw.write(",");
bw.write("componentDesc");
bw.write(" ") ;
bw.newLine();
Iterator<RepairCatalogSearchResultsVO> ite = rowDataList.iterator();
while (ite.hasNext()) {
RepairCatalogSearchResultsVO vo = ite.next();
bw.write(vo.getAtaNum());
bw.write(",");
bw.write(vo.getComponentDesc());
bw.write(" ") ;
bw.newLine();
}
//close
bw.close();
osw.close();
out.close();
}
catch(Exception e){
e.printStackTrace() ;
}
}