星空报表
http://download.enet.com.cn/html/030212006012001.html
优点:
功能比较全面,可以作为独立的报表服务器使用,也可以内嵌到其他web应用中,输出格式包括pdf、excel、rtf等,支持任务订制、历史报表存储、在线自定义报表(WEB创作)等。
缺点:
免费使用
http://download.enet.com.cn/html/030212006012001.html
优点:
功能比较全面,可以作为独立的报表服务器使用,也可以内嵌到其他web应用中,输出格式包括pdf、excel、rtf等,支持任务订制、历史报表存储、在线自定义报表(WEB创作)等。
缺点:
免费使用
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
employee.dept=部门
就行了
我还自己去写了生成CSV的bean