码迷,mamicode.com
首页 > 编程语言 > 详细

Java通过POI读取Excel

时间:2018-05-16 13:08:43      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:xlsx   ack   work   mode   read   throw   import   []   imp   

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));
*/
    }

}

 

Java通过POI读取Excel

标签:xlsx   ack   work   mode   read   throw   import   []   imp   

原文地址:https://www.cnblogs.com/suhfj-825/p/9044663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!