国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

excle報盤之導出處理失敗數據

2019-11-08 01:52:12
字體:
來源:轉載
供稿:網友

前端jsp:

<div class="blockhead">					<span>處理失敗數據導出</span>						<form id="importForm" action="" method="post" enctype="multipart/form-data" style="float: right;margin-right: 20px;padding-top: 3px;">							<input type="file" name="textfield" class="file" style="width:170px;" id="textfield" height="22px"    /> 							<!--<a href="javascript:void(0)" style="background-color: #ff6600;margin-left: 0px;" onclick="importData()">導入</a> -->							<a href="${base!}/get_export.do?Id="+id  style="background-color: #057ac5;margin-left: 0px;">導出處理失敗數據</a>							</form>				</div>

servlet:

	@RequestMapping(value = "get_export.do")	public void doExport(HttpServletRequest request, HttpServletResponse response,String id) {		OutputStream out = null;		try {			String path = request.getsession().getServletContext().getRealPath("/");			String fileName = new String(("報盤(處理失敗數據).xls").getBytes("GBK"), "ISO8859_1");			response.setContentType("application/vnd.ms-Excel");			response.setHeader("Content-disposition", "attachment;filename=/"" + fileName + "/"");			out = response.getOutputStream();			importExcelMng.createExcelExport(path + "/WEB-INF/excelTemplate/zj-error.xls", out, aqb080Id);		} catch (Exception ex) {			ex.PRintStackTrace();		} finally {			try {				out.close();			} catch (IOException e) {				e.printStackTrace();			}		}	}zj-error.xls存放位置:

項目根目錄:

/WEB-INF/excelTemplate/zj-error.xls

處理類:

importExcelMng.createExcelExport

@Override	public void createExcelExport(String path, OutputStream out, String Id) {		InputStream inputSteam = null;		//通過主表信息主鍵查詢處理失敗數據		List<BpWeb> BpWebList = BpWebDao.queryList(Id);		try {			inputSteam = new FileInputStream(path);			HSSFWorkbook wb = new HSSFWorkbook(inputSteam);			wb.setSheetName(0, "報盤處理失敗數據");			HSSFSheet sheet = wb.getSheetAt(0);			HSSFRow titleRow = null;			titleRow = sheet.getRow(0);			if (titleRow == null) {				titleRow = sheet.createRow(0);			}			titleRow.setHeight((short)600);			Cell cell0 = prepareCell(titleRow, 0);			cell0.setCellValue("處理標志");			Cell cell1 = prepareCell(titleRow, 1);			cell1.setCellValue("處理日期");			Cell cell2 = prepareCell(titleRow, 2);			cell2.setCellValue("處理失敗原因");			Cell cell3 = prepareCell(titleRow, 3);			cell3.setCellValue("身份證號");			Cell cell4 = prepareCell(titleRow, 4);			cell4.setCellValue("姓名");			Cell cell5 = prepareCell(titleRow, 5);			cell5.setCellValue("類別");			Cell cell6 = prepareCell(titleRow, 6);			cell6.setCellValue("類別2");			Cell cell7 = prepareCell(titleRow, 7);			cell7.setCellValue("畢業院校");			Cell cell8 = prepareCell(titleRow, 8);			cell8.setCellValue("畢業時間");			Cell cell9 = prepareCell(titleRow, 9);			cell9.setCellValue("開始年月");			Cell cell10 = prepareCell(titleRow,10);			cell10.setCellValue("終止年月");						int rowNum = 1;			for(int i=0;i<BpWebList.size();i++) {				BpWeb BpWeb = BpWebList.get(i);				HSSFRow row = null;				row = sheet.getRow(rowNum);				if (row == null) {					row = sheet.createRow(rowNum);				}				rowNum ++;				row.setHeight((short)400);				Cell cell_n0 = prepareCell(row, 0);				cell_n0.setCellValue(formatString(getA103("BP003",BpWeb.getBp003())));				Cell cell_n1 = prepareCell(row, 1);				cell_n1.setCellValue(formatString(BpWeb.getBp009()));				Cell cell_n2 = prepareCell(row, 2);				cell_n2.setCellValue(formatString(BpWeb.getBp004()));				Cell cell_n3 = prepareCell(row, 3);				cell_n3.setCellValue(formatString(BpWeb.getA002()));				Cell cell_n4 = prepareCell(row, 4);				cell_n4.setCellValue(formatString(BpWeb.getA003()));				Cell cell_n5 = prepareCell(row, 5);				cell_n5.setCellValue(formatString(getA103("A012",BpWeb.getA012())));				Cell cell_n6 = prepareCell(row, 6);				cell_n6.setCellValue(formatString(getA103("A029",BpWeb.getA029())));				Cell cell_n7 = prepareCell(row, 7);				cell_n7.setCellValue(formatString(BpWeb.getA045()));				Cell cell_n8 = prepareCell(row, 8);				cell_n8.setCellValue(formatString(BpWeb.getA046()));			}						inputSteam.close();			wb.write(out);			wb.close();		} catch (IOException e) {			e.printStackTrace();		}	}	public Cell prepareCell(Row row, int index) {		Cell cell = row.getCell(index);		if (cell == null) {			cell = row.createCell(index);		}		return cell;	}		private String formatString(Object text) {		if (text == null) {			return "";		}		return String.valueOf(text);	}

相關類 :

BpWeb等在此省略


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 精河县| 时尚| 都匀市| 临澧县| 鄂温| 儋州市| 会宁县| 饶阳县| 库车县| 绵竹市| 阳信县| 林甸县| 汝阳县| 东港市| 共和县| 长丰县| 呼和浩特市| 洛宁县| 错那县| 奉新县| 治多县| 东山县| 宜春市| 桐乡市| 广饶县| 柳州市| 德清县| 苏尼特左旗| 保靖县| 盈江县| 潜山县| 辽源市| 田阳县| 东山县| 仲巴县| 和硕县| 和硕县| 郴州市| 凉城县| 绥棱县| 龙江县|