zoukankan      html  css  js  c++  java
  • 通过poi解析excel

    1、添加相应的jar包

    2、使用方法如下:

    Workbook workbook= WorkbookFactory.create(new File("f:/upload/"+fileName));  //创建Workbook对象来解析对应的excel
                    Sheet sheet=workbook.getSheetAt(0);                          //通过索引找到相应的sheet
                    int rownum=sheet.getLastRowNum();                 //找到最后一行
                    for (int i = 1; i <=rownum; i++) {                //遍历每一行
                        Row row=sheet.getRow(i);                    //通过Row对象得到行的数据
                        Student student=new Student();                //通过student对解析到的数据进行封装
                        student.setName(row.getCell(0).getStringCellValue());    //对获取的数据设置相应的格式
                        student.setAge((int)row.getCell(1).getNumericCellValue());
                        student.setDate(row.getCell(2).getDateCellValue());
                        studentList.add(student);
  • 相关阅读:
    C语言I博客作业09
    C语言I博客作业08
    第十四周助教总结
    C语言I博客作业07
    第十三周助教总结
    C语言I博客作业06
    第十二周助教总结
    学期总结
    C语言I博客作业09
    C语言I博客作业08
  • 原文地址:https://www.cnblogs.com/shouyaya/p/12088864.html
Copyright © 2011-2022 走看看