package com.hd.all.test.testjava;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcelPOI {
public static void main(String[] args) throws FileNotFoundException, IOException {
//students2017-10-19_11_22_52.xls-->这个也可以用下面代码读取到,因为这个文件用.xlsx应该用的对象生成的,本质是.xlsx
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("E:/students2017-10-19_11_23_33.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
System.out.println(row.getCell(0));
/* HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(new File("E:/students2017-10-19_10_55_55.xls")));
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFRow row = sheet.getRow(0);
System.out.println(row.getCell(0));
*/
}
}