public void resultSetToExcel(ResultSet rs, String excelName,
			String sheetName) {
		try {
			HSSFWorkbook workbook = new HSSFWorkbook();
			HSSFSheet sheet = workbook.createSheet();
			workbook.setSheetName(0, sheetName);
			HSSFRow row = sheet.createRow((short)0);
			HSSFCell cell;
			ResultSetMetaData md;
			md = rs.getMetaData();
			int colCount = md.getColumnCount();
			
			for(int i = 1;i <= colCount;i++) {
				cell = row.createCell((short)(i -1));
				cell.setCellType(HSSFCell.CELL_TYPE_STRING);
				cell.setCellValue(md.getColumnLabel(i));
			}
			
			int iRow = 1;
			while(rs.next()) {
				row = sheet.createRow((short)iRow);
				for(int j = 1; j <= colCount;j++) {
					cell = row.createCell((short)(j-1));
					cell.setCellType(HSSFCell.CELL_TYPE_STRING);
					cell.setCellValue(rs.getObject(j).toString());
				}
				iRow++;
			}
			
			FileOutputStream outputStream = new FileOutputStream(excelName);
			workbook.write(outputStream);
			outputStream.flush();
			outputStream.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}