/* Conroller.java */
/**
* Excel Download
*
* @return java.lang.String
*/
@RequestMapping(value = "/excelCustomer", method = RequestMethod.POST)
public String excelCustomer(@RequestParam Map<String,Object> params, ModelMap model,
HttpServletResponse response) throws Exception {
//response.setHeader("Content-disposition","inline; filename=customer.xls");
ResultMap resultMap = customerServiceImpl.excelCustomer(params);
model.put("total_cnt", resultMap.get("total_cnt"));
model.put("customer_list", resultMap.get("list"));
return "sample/customer/excel";
}
/* excel.jsp */
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page contentType="application/vnd.ms-excel; charset=utf-8"%>
<%
//******************************MS excel******************************
// MS excel로 다운로드/실행, filename에 저장될 파일명을 적어준다.
response.setHeader("Content-Disposition","attachment;filename=member.xls");
response.setHeader("Content-Description", "JSP Generated Data");
//이걸 풀어주면 열기/저장 선택창이 뜨는 게 아니라 그냥 바로 저장된다.
// response.setContentType("application/vnd.ms-excel");
%>
<html>
<head>
<title>고객</title>
<meta http-equiv='Content-Type' content='application/vnd.ms-excel; charset=utf-8'/>
<style type="text/css">
.tbl_grid {border:1px solid #333333;width:1000px;clear:both;line-height:15px;}
.tbl_grid th {padding:8px 0;border:1px solid #666666;text-align:center;font-size:11px;font-weight:normal;color:#444;background:#dedede;line-height:14px;}
.tbl_grid td {padding:8px;font-size:11px;color:#444;border:1px solid #666666;text-align:center;background:#ffffff;}
.tbl_grid .td01 {background:#f2f4f4;}
.tbl_grid .tleft {text-align:left;padding-right:4px;}
.tbl_grid .tright {text-align:right;padding-right:4px;}
</style>
</head>
<body>
<table class="tbl_grid">
<colgroup>
<col />
<col />
<col />
<col />
<col />
<col />
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th>고객코드</th>
<th>고객명</th>
<th>핸드폰</th>
<th>회사명</th>
<th>회사전화</th>
<th>메일</th>
<th>보유자산</th>
<th>등록일</th>
</tr>
</thead>
<tbody>
<c:forEach var="result" items="${customer_list}" varStatus="status">
<tr>
<td><c:out value="${result.cust_id}"/></td>
<td><c:out value="${result.cust_nm}"/></td>
<td><c:out value="${result.cpy_telno}"/></td>
<td><c:out value="${result.company_nm}"/></td>
<td><c:out value="${result.company_telno}"/></td>
<td><c:out value="${result.email}"/></td>
<td style="text-align:right;padding-right:4px;"><c:out value="${result.money}"/></td>
<td><c:out value="${result.reg_dt}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
댓글 없음:
댓글 쓰기