| | |
| | | |
| | | public static Map<String, XSSFPictureData> getExcelPictures(InputStream is) { |
| | | try { |
| | | byte[] fileData = getFileStream(is); |
| | | byte[] fileData = toByteArray(is); |
| | | Map<String, XSSFPictureData> pictures = getPictures(fileData); |
| | | pictures.forEach((id, xssfPictureData) -> { |
| | | System.out.println("id:" + id); |
| | |
| | | } |
| | | |
| | | } |
| | | public static byte[] toByteArray(InputStream input) throws IOException { |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | int bytesRead; |
| | | byte[] buffer = new byte[1024]; // 可以根据需要调整缓冲区大小 |
| | | while ((bytesRead = input.read(buffer)) != -1) { |
| | | byteArrayOutputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | return byteArrayOutputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 获取浮动图片,以 map 形式返回,键为行列格式 x-y。 |