zoukankan      html  css  js  c++  java
  • Excel最简洁解析

    public static void main(String[] args) {

      File file = new File("D://123.xlsx");
      try {
        InputStream is = new FileInputStream(file);
        Workbook wb = null;
        if (file.getName().endsWith("xls")) { //Excel 2003
          try {
            wb = new HSSFWorkbook(is);
          } catch (IOException e) {
            e.printStackTrace();
          }
        } else if(file.getName().endsWith("xlsx")) { // Excel 2007/2010
          try {
            wb = new XSSFWorkbook(is);
          } catch (IOException e) {
            e.printStackTrace();
          }   
        }

        for (Sheet sheet : wb) {
          for (Row row : sheet) {
            StringBuffer sb = new StringBuffer();
            for (Cell cell : row) {
              sb.append(cell.toString());
            }
            System.out.println(sb);
          }
        }
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }

  • 相关阅读:
    第九周
    第七周.
    第六周.
    第二次作业
    第九周作业
    第八周作业
    第七周作业
    第六周作业
    第五周作业
    统计一行文本的单词个数
  • 原文地址:https://www.cnblogs.com/lh-masteryi/p/9087120.html
Copyright © 2011-2022 走看看