package com.zuxia.execl;
import java.io.File;
import java.io.FileInputStream;
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 ReaderExcel {
public static void main(String[] args) throws Exception{
File excelFile = new File("e:/a.xls");
FileInputStream is = new FileInputStream(excelFile);// 获取文件输入流
//根据文件流,找到工作薄
HSSFWorkbook workbook2003 = new HSSFWorkbook(is);// 创建Excel2003文件对象
//工作表
HSSFSheet sheet = workbook2003.getSheetAt(0);
for(int i=0;i<=sheet.getLastRowNum();i++){
HSSFRow row = sheet.getRow(i);// 获取行对象
for(int j=0;j<row.getLastCellNum();j++){
HSSFCell cell = row.getCell(j);
System.out.print(cell.getStringCellValue()+"\t");
}
System.out.println();
}
is.close();
}
}
import java.io.File;
import java.io.FileInputStream;
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 ReaderExcel {
public static void main(String[] args) throws Exception{
File excelFile = new File("e:/a.xls");
FileInputStream is = new FileInputStream(excelFile);// 获取文件输入流
//根据文件流,找到工作薄
HSSFWorkbook workbook2003 = new HSSFWorkbook(is);// 创建Excel2003文件对象
//工作表
HSSFSheet sheet = workbook2003.getSheetAt(0);
for(int i=0;i<=sheet.getLastRowNum();i++){
HSSFRow row = sheet.getRow(i);// 获取行对象
for(int j=0;j<row.getLastCellNum();j++){
HSSFCell cell = row.getCell(j);
System.out.print(cell.getStringCellValue()+"\t");
}
System.out.println();
}
is.close();
}
}