我正在尝试将“JPEG”图像文件粘贴到Excel 2013 32位版本。但在我打开它后编写工作簿后,我收到错误“当前无法显示图像”。图像文件非常大。
我正在使用带有Microsoft Excel 32位版本的Windows 7 64位。
这是在apache POI文档之后粘贴图像的代码部分。 -
XSSFDrawing drawing = sheet.createDrawingPatriarch();
InputStream graphImage = new FileInputStream(fileName);
//Byte array to store the Image in Byte format
byte[] bytes = IOUtils.toByteArray(graphImage);
//Image Id
int imageId = frameWorkbook.addPicture(bytes,Workbook.PICTURE_TYPE_JPEG);
graphImage.close();
//Instance of ClientAnchor
ClientAnchor anchor = new XSSFClientAnchor();
anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);
//Setting start position of the Image
anchor.setCol1(5);
anchor.setRow1(5);
//Instance of XSSFpicture to paint the image
XSSFPicture picOfGraph = drawing.createPicture(anchor,imageId);
picOfGraph.resize();
此代码适用于小尺寸图像,但如果图像尺寸变大,那么我收到错误????任何解决方案??