关于Java当中利用Excel表格模板在后台导出Excel表格

请各位大牛指点一下为什么低版本的ie6导出时没有数据。
前台代码:

// 
<form id="excel_sqwdxxgl"  action="${pageContext.request.contextPath}/jkgl/ywgl/sqwdxxgl/dysqwdxxgl.action" method="post" target="excelIFrame"> 
		<input type="hidden" name="ssqx2" id="ssqx2"/>
		<input type="hidden" name="sqmc2" id="sqmc2"/>
		<input type="hidden" name="sqbh2" id="sqbh2"/>
		<input type="hidden" name="sfwzlwd2" id="sfwzlwd2"/>
	</form>
```javascript
ssqx = mini.get("ssqx").getFormValue();
	sqmc = mini.get("sqmc").getFormValue();
	sqbh = mini.get("sqbh").getFormValue();
	sfwzlwd = mini.get("sfwzlwd").getFormValue();
function ExportExcel() {   	
		 document.getElementById("wdmc2").value = wdmc;
		 document.getElementById("wdbh2").value = wdbh;
		 document.getElementById("ssqx2").value = ssqx;
		 document.getElementById("kzzd52").value = kzzd5;
		 var excelForm = document.getElementById("excel_yhwdxxgl");
		 excelForm.submit();
	} 

后台代码:

// action层:
public void dysqwdxxgl(){
		try{
			String ssqx = this.servletRequest.getParameter("ssqx2");
			String sqmc = this.servletRequest.getParameter("sqmc2");
			String sqbh = this.servletRequest.getParameter("sqbh2");
			String sfwzlwd = this.servletRequest.getParameter("sfwzlwd2");
			SqwdxxglBO sqwdxxglBO = new SqwdxxglBO();
			sqwdxxglBO.setSsqx(ssqx);
			sqwdxxglBO.setSqmc(sqmc);
			sqwdxxglBO.setSqbh(sqbh);
			sqwdxxglBO.setSfwzlwd(sfwzlwd);
			sqwdxxglService.export(sqwdxxglBO);
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
// serviceIMPL层:
@Override
	public List<SqwdxxglDTO> export(SqwdxxglBO sqwdxxglBO) throws Exception {
		List<SqwdxxglDTO> list = sqwdxxglDAO.querySqwdxxForList(sqwdxxglBO);
		if(list.size()<0){
			throw new Exception("系统错误!");
		}else{
			for(int i=0;i<list.size();i++){
				String sqlx = list.get(i).getSqlx();
				String zf = list.get(i).getSfwzlwd();
				if(sqlx != null){
					sqlx = sqlx.substring(0, sqlx.length()-1);
					list.get(i).setSqlx(sqlx);
				}
				if("1".equals(zf)){
					list.get(i).setSfwzlwd("是");
				}else if("0".equals(zf)){
					list.get(i).setSfwzlwd("否");
				}
			}
			OutputStream ouputStream = null;
			HttpServletResponse response = ServletActionContext.getResponse();
			HSSFWorkbook wb = new HSSFWorkbook(
					ServletActionContext.getServletContext()
					.getResourceAsStream("ExcelTemplet/社区网点信息管理.xls"));
			HSSFSheet sheet = wb.getSheetAt(0);
			sheet.getPrintSetup().setLandscape(true);
			HSSFCellStyle style = wb.createCellStyle();
			style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
			style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
			style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
			style.setBorderTop(HSSFCellStyle.BORDER_THIN);
			style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
			HSSFRow row = sheet.createRow((int) 2);
			for(int i=0;i<list.size();i++){
				row = sheet.createRow(i + 2);
				HSSFCell cell0 = row.createCell((short)0);
				HSSFCell cell1 = row.createCell((short)1);
				HSSFCell cell2 = row.createCell((short)2);
				HSSFCell cell3 = row.createCell((short)3);
				HSSFCell cell4 = row.createCell((short)4);
				HSSFCell cell5 = row.createCell((short)5);
				HSSFCell cell6 = row.createCell((short)6);
				HSSFCell cell7 = row.createCell((short)7);
				HSSFCell cell8 = row.createCell((short)8);
				HSSFCell cell9 = row.createCell((short)9);
				HSSFCell cell10 = row.createCell((short)10);
				cell0.setCellStyle(style);
				cell1.setCellStyle(style);
				cell2.setCellStyle(style);
				cell3.setCellStyle(style);
				cell4.setCellStyle(style);
				cell5.setCellStyle(style);
				cell6.setCellStyle(style);
				cell7.setCellStyle(style);
				cell8.setCellStyle(style);
				cell9.setCellStyle(style);
				cell10.setCellStyle(style);
				cell0.setCellValue(i+1);
				cell1.setCellValue(new HSSFRichTextString(list.get(i).getSqbh()));
				cell2.setCellValue(new HSSFRichTextString(list.get(i).getSqmc()));
				cell3.setCellValue(new HSSFRichTextString(list.get(i).getSqlx()));
				cell4.setCellValue(new HSSFRichTextString(list.get(i).getSsqx()));
				cell5.setCellValue(new HSSFRichTextString(list.get(i).getDz()));
				cell6.setCellValue(new HSSFRichTextString(list.get(i).getLxdh()));
				cell7.setCellValue(new HSSFRichTextString(list.get(i).getJzzwddz()));
				cell8.setCellValue(new HSSFRichTextString(list.get(i).getJzzwddh()));
				cell9.setCellValue(new HSSFRichTextString(list.get(i).getSfwzlwd()));
				cell10.setCellValue(new HSSFRichTextString(list.get(i).getBz()));
			}
			response.setContentType("application/vnd.ms-excel");  
			response.setHeader("Content-disposition", "attachment;filename="+StringUtil.toUtf8String("社区网点信息管理表")+".xls");  
			ouputStream = response.getOutputStream();
			wb.write(ouputStream);  
			ouputStream.flush();
		}
		return list;
	}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值