private void exportAssetExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { String ogid = RequestUtil.getRequestBytes(request, "ogid").trim(); String objectgroupname = RequestUtil.getRequestBytes(request, "objectgroupname").trim(); String excelTitle = new String(objectgroupname.getBytes("ISO-8859-1"), "utf-8"); if(objectgroupname==null || objectgroupname==""){ objectgroupname = "备播单"; } ObjectGroupRObjectMgr ogroMgr = new ObjectGroupRObjectMgr(); BaseDAO basedao = ogroMgr.getBasedao(); String strCondition= "select " + " ogro.new_assetname," + " a.assetname," + " m.filepath," + " a.programtype," + " a.videotype," + " a.duration," + " ogro.asset_price," + " ogro.online_time," + " ogro.asset_path" + " from " + " Objectgrouprobject ogro," + " movie m," + " asset a " + " where " + " ogro.objectid = a.assetid" + " and a.assetid = m.objectguid" + " and ogro.ogid = ?" + " order by ogro.ordernum asc"; List paramlist = new ArrayList(); paramlist.add(ogid); // 关联objectgrouprobject asset查询 List
以上是java部分的代码, 导出按照workbook-->sheet-->row-->cell的大体流程走, 再加上格式设置, 加上值等等
前端需要弹出下载框,可以用:
window.open("objectgroup.do"+"?action=exportAssetExcel&ogid="+ogid+"&objectgroupname="+objectgroupname);
或者用form提交
jsp页面
js处理
$("#searchXML").val(searchXML); $("#exportExcel_program_form").submit();
这里参数可能有中文,所以java部分要处理,可以参见上面java代码