| | |
| | | workbook = WorkbookFactory.create(inputStream); |
| | | inputStream.close(); |
| | | List<? extends PictureData> allPictures = workbook.getAllPictures(); |
| | | if(fileTempUrl.substring(fileTempUrl.lastIndexOf(".")+1).equals("xlsx")) { |
| | | Collections.sort(allPictures, new Comparator<PictureData>() { |
| | | @Override |
| | | public int compare(PictureData o1, PictureData o2) { |
| | | // Name: /xl/media/image1.png - Content Type: image/png |
| | | String s1 = o1.toString(); |
| | | int contentTypeIndex = s1.indexOf(" - Content Type"); |
| | | String s1Front = s1.substring(0, contentTypeIndex); |
| | | String imageNumStr1 = s1Front.substring(s1Front.lastIndexOf("/") + 1, s1Front.lastIndexOf(".")).replace("image", ""); |
| | | |
| | | String s2 = o2.toString(); |
| | | int contentTypeIndex2 = s2.indexOf(" - Content Type"); |
| | | String s2Front = s2.substring(0, contentTypeIndex2); |
| | | String imageNumStr2 = s2Front.substring(s2Front.lastIndexOf("/") + 1, s2Front.lastIndexOf(".")).replace("image", ""); |
| | | |
| | | return Integer.parseInt(imageNumStr1) - Integer.parseInt(imageNumStr2); |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | //取第一个sheet表 |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | int lastRowNum = sheet.getLastRowNum(); |