'2009/10'에 해당되는 글 2건

  1. 2009.10.16 엑셀 파일 읽어와서 화면에 출력하는 소스

<%@ page isErrorPage="true" contentType="application/vnd.ms-excel;

          charset=euc-kr" %>
<%@ page language="java" import="java.sql.*, java.io.*, jxl.*" %>
<%
     String path = "C:\\Documents and Settings\\Administrator\\바탕 화면";
     String filename = "Book1.xls";

     Workbook workbook = Workbook.getWorkbook(new File(path+"\\"+filename));
     Sheet sheet = workbook.getSheet(0);

     int col = sheet.getColumns();  // 시트의 컬럼의 수를 반환한다.
     System.out.println("col"+col);
     int row = sheet.getRows();   // 시트의 열의 수를 반환한다.
     System.out.println("row"+row);
%>
<HTML>

<HEAD>
    <TITLE>Excel Upload</TITLE>
</HEAD>

<BODY>
    <FORM name='bcl' method='post'>
    <TABLE cellspacing="0" cellpadding="6" border="1">
    <%
        int tmpCellLen = 0;
        for(int i=0 ; i<row ; i++){  // Record를 읽어 배열로 저장
            Cell cell [] = sheet.getRow(i);
            tmpCellLen = cell.length; 

            out.println("<tr>");
            for (int j=0; j<col ; j++) {   // 레코더의 전체 컬럼수 만큼 반복
                if (j < tmpCellLen)  {
                    out.println("<td>"+cell[j].getContents()+"</td>");
                    System.out.println("내용"+cell[j].getContents());
                } else {
                    out.println("<td>&nbsp;</td>");
                    System.out.println("내용없음");
                } // end of if
            }
            out.println("</tr>");
        } // end of for
    %>
    </TABLE>
    </FORM>
</BODY>
</HTML>
*****************************************************************

Posted by ▶파이팅◀
이전버튼 1 2 이전버튼

블로그 이미지
Let's start carefully from the beginning
▶파이팅◀

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2009.10
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

글 보관함