Html을 Excel로 나타낼때 형식
참고/웹개발 : 2008/03/27 15:18
-
원문 : http://www.jakartaproject.com/article/jsptip/111076895041700
JSP에서 html을 간단히 엑셀 파일로 나타내려 할때 다음과 같이 하곤 합니다.<%@ page language="java" contentType="application/vnd.ms-excel; charset=euc-kr" %>
<%
response.setHeader("Content-Disposition", "attachment; filename=excel.xls");
response.setHeader("Content-Description", "JSP Generated Data");...
%>
헌데 나타낼려는 값이 00000001 인데 실제적으로 엑셀 파일을 열어보면 1로 나타납니다.
엑셀이 00000001을 1로 나타내 버리는거죠..
꽁수를 쓰자면 00000001다음에 값을 주어 이를 처리할 수도 있지만 먼가 좀 꺼림직 하죠
이와 같은 경우에 다음과 같이 스타일을 이용하여 이를 해결 할 수 있습니다.
<td style='mso-number-format:\@'>00000001</td>
이밖에 다음과 같은 스타일이 더 있으니 참고하세요
- Text : mso-number-format:\@
- 3 decimals : mso-number-format:"0\.000"
- Comma separators (and 3 decimals) : mso-number-format:\#\,\#\#0\.000
- Date format : mso-number-format:"mm\/dd\/yy"
- Another date format : mso-number-format:"d\\-mmm\\-yyyy"
- Percent : mso-number-format:Percent
- 3 decimals : mso-number-format:"0\.000"
Trackback Address :: http://jjangu.pe.kr/blog/trackback/502



