eclipse中maven读取Excel文件内容

package demo;

public class userinfo {
	
	private String username;
	private String password;
	private Integer jf;
	
	public userinfo(String name,String passwd,Integer j){
		this.username = name;
		this.password = passwd;
         	this.jf = j;
		
	}
	
	public String getUsername() {
		return username;
	}
	public String getPassword() {
		return password;
	}
	public Integer getJf() {
		return jf;
	}
}


package demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

public class read_execl {

	public static void main(String[] args) throws Exception {
		
		File execlfile = new File("c:\\userinfo.xls");
		FileInputStream execlstream = new FileInputStream(execlfile);
		Workbook wb = new HSSFWorkbook(execlstream);
//		Sheet sheet = wb.getSheetAt(0);
		Sheet sheet = wb.getSheet("Sheet1");
		Row row = sheet.getRow(0);
//		Cell cell = row.getCell(1);
		System.out.println(sheet.getLastRowNum());
		System.out.println(row.getCell(0).getStringCellValue());
	}

}

 

posted @ 2017-02-23 15:59  六个明天以后  阅读(2658)  评论(0编辑  收藏  举报