Aspose.cells for java插入图片问题

测试的产品是:aspose.cells for java;
出现的问题:根据模板占位符 导入图片,现在导入宽度有问题;想要读取表格 然后根据表格大小定制图片的大小;
截图如下:
QQ图片20171220103213.png (8.4 KB)

@zg0x1231

感谢您使用的Aspose的API。

请设置列宽和行高,按您的画面。请看下面的示例代码,它的样本Excel文件,输出Excel文件以及屏幕截图显示代码的效果。

下载链接:
Sample Input and Output Excel Files.zip (309.1 KB)

如果它不能解决您的问题,那么请提供我们您的示例输入和输出Excel文件和示例代码来复制这个问题,我们将研究它,并尽快帮助你。

Java

//Load the Excel file containing picture
Workbook wb = new Workbook("sample.xlsx");

//Access the first worksheet
Worksheet ws = wb.getWorksheets().get(0);
            
//Access the first picture
Picture pic = ws.getPictures().get(0);

//Set the column width and row height as per picture
ws.getCells().setColumnWidthPixel(2, pic.getWidth());
ws.getCells().setRowHeightPixel(2, pic.getHeight());

//Save the output Excel file
wb.save("output.xlsx");

Screenshot