xiaoliu66007
public static Workbook create(InputStream in) throws     
    IOException,InvalidFormatException {
        if (!in.markSupported()) {
            in = new PushbackInputStream(in, 8);
        }
        if (POIFSFileSystem.hasPOIFSHeader(in)) {
            return new HSSFWorkbook(in);
        }
        if (POIXMLDocument.hasOOXMLHeader(in)) {
            return new XSSFWorkbook(OPCPackage.open(in));
        }
        throw new IllegalArgumentException("你的excel版本目前poi解析不了");

    }
读写xls和xlsx格式时,HSSFWorkbook针对xls,XSSFWorkbook针对xlsx

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-22
  • 2021-11-26
  • 2021-12-23
  • 2022-01-17
  • 2021-11-25
  • 2022-12-23
相关资源
相似解决方案