Jexel 초간단 사용해보기

개발/프로그래밍2008. 1. 2. 19:22
728x90


다음 사이트에서 메뉴얼이나 jar 파일을 구할 수 있다.

http://www.andykhan.com/jexcelapi/

 

import java.io.*; // 파일 입력 관련 클래스

import jxl.*; // jxl 관련 클래스

 

public class Read_exel{

 

public static void  main(String args[]) throws FileNotFoundException, IOException,jxl.read.biff.BiffException{

      Workbook myWorkbook = Workbook.getWorkbook(new File("D:\\book1.xls"));

     /* 읽을 파일에 대한 경로 지정 */

     Sheet mySheet = myWorkbook.getSheet(0);

 

     int row_count = mySheet.getRows();   /* Row 갯수 */

     int column_count= mySheet.getColumns(); /* Column 갯수 */

          

        for(int title_i=0;title_i<column_count;title_i++){

          Cell myTitle = mySheet.getCell(title_i,0);

         System.out.print(myTitle.getContents()+ "\t");

 

          }  //타이틀 관련 출력하는 부분이다.

       

         for(int num=1;num<row_count;num++){

              for(int i=0;i<column_count;i++){

                Cell myCell = mySheet.getCell(i,num); // Row, Column의 대한 정보를 가져 온다.

                System.out.print(myCell.getContents()+"\t"); // 내용을 출력하다.

                  }

            System.out.println();

          }

     }

}

728x90

작성자

Posted by 일퍼센트

관련 글

댓글 영역