JAva HSSF excel読み出し


poi-2.5.1.jarで
package com.cal.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class ParserExcelUtils {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List<String> emailList = ParserExcelUtils.ParserExcel("c://database.xls");
		System.out.println(emailList.size());
	}

	public static List<String> ParserExcel(String fullFilePath){
		List<String> list = new ArrayList<String>();
		//   xls      wb 
		try {
			HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(new File(fullFilePath)));
			//     ,    excel         ,                    
			HSSFSheet sheet = wb.getSheetAt(0);
			//     sheet.getLastRowNum()                ,
			//     3   ,            2,    0   
			for(int j=0;j<sheet.getLastRowNum()+1;j++) {
			//       
				HSSFRow row = sheet.getRow(j);
				//              
				for(int i=0;i<row.getLastCellNum();i++) {
					//              ,               
					HSSFCell cell = row.getCell((short)i);
					//                   ,            
//					System.out.println(cell.getStringCellValue());
					list.add(cell.getStringCellValue());
				}
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	
}

参考になるhttp://www.iteye.com/topic/388005