excel支持2013版本和2017版本

创建提个工具类XlsImpUtil

public class XlsImpUtil {

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

}
Workbook xssfWorkbook = XlsImpUtil.create(inputStream);

 Sheet xssSheet0 = xssfWorkbook.getSheetAt(0);

Cell 使用cell

 

你可能感兴趣的:(java)