1、poi帮助文档:
API:http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFCell.html
poi包:http://pan.baidu.com/s/1hmIQU
2、小知识点
1.sheet, 以0开始,以workbook.getNumberOfSheets()-1结束
2.row, 以0开始(getFirstRowNum),以getLastRowNum结束
3.cell, 以0开始(getFirstCellNum),以getLastCellNum结束
3、例子:
excel内容的值如果不是string,则用getNumericCellValue(),得到double类型,再做相应转换,如果为string,则用getStringCellValue()
double转换为int:int i_yhfw= (int) Double.parseDouble(Demo.getExcel(index, 13));
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
/**
* 获取excel文件
* index为sheet页,从0开始
* rowNum为行数,从0开始
* 从来colNumNum为列数,从0开始
* 只能读取excel2003(2003的后缀名是.xls)
*/
public static String getExcel(int index,int rowNum,int colNum){
//String Divpath="C:/Users/gmsd11/workspace";//文件保存的路径