poi解析excel遇到的問題
阿新 • • 發佈:2018-12-07
問題一
poi對excel版本問題可用
Workbook workbook;
workbook = WorkbookFactory.create(upload);
Sheet sheet=workbook.getSheetAt(0);
maven 引入以來如下
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.15</version> </dependency> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>com.github.virtuald</groupId> <artifactId>curvesapi</artifactId> <version>1.05</version> </dependency>
問題二
poi不能直接解析excel中的純數字需要把數字轉換成字串
如
Cell numcell=row.getCell(2);
numcell.setCellType(CellType.STRING);
Integer num=Integer.parseInt(numcell.getStringCellValue());
問題三
poi獲取excel中的時間
Date time=timeCell.getDateCellValue();