°øÀ¯ÀÚ·á HOME > ÀÚ·á½Ç > °øÀ¯ÀÚ·á
 
[ºòµ¥ÀÌÅͺм®·Ð]ReadExcel.java
°ü¸®ÀÚ 15-04-01 13:22 1,067
   ReadExcel.zip (971.5K) [51] DATE : 2015-04-01 13:22:00
import java.io.File;
import java.io.IOException;
 
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
 
 
public class ReadExcel {
 
    public static void main(String[] args) {
 
        
        // ÆÄÀÏ °´Ã¼ »ý¼º - ¿¢¼¿ÆÄÀÏ °æ·Î
        File file = new File("G:\\ÀÚ¹Ù¼÷Á¦\\test.xls");
        
        
        
        
        try {
            
            // ¿¢¼¿ÆÄÀÏ ¿öÅ©ºÏ °´Ã¼ »ý¼º
            Workbook workbook = Workbook.getWorkbook(file) ;
            
            // ½ÃÆ® ÁöÁ¤
            Sheet sheet = workbook.getSheet(0);
            
            // Çà ±æÀÌ
            int endIdx = sheet.getColumn(1).length-1;
            
            
            for(int i=0; i <= endIdx; i++){
                
                // ù¹ø° ¿­(A)
                String name = sheet.getCell(0, i).getContents() ;
                
                // µÎ¹ø° ¿­(B)
                String age = sheet.getCell(1, i).getContents() ;
                
                
                
                System.out.println(name + " : " + age) ;
                
                
            }
            
            
            
            
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
 
}
 
// javac ReadExcel.java -classpath G:\ÀÚ¹Ù¼÷Á¦\jxl-2.6.3.jar ¶ó°í compileÇÑ´Ù