您好,经初步研判认定该问题是一个Bug,目前正在修复中,临时的解决方案请参考以下代码:
将autoFit提前于设置图片。
for (int i = 0; i < count; i++) {
IRange iRange = usedRange.getRows().get(i);
double before = iRange.getHeight();
for (int i1 = 0; i1 < col; i1++) {
IRange cell = iRange.getColumns().get(i1);
if (cell.getValue() != null && cell.getValue().toString().contains("sign::")) {
int x = i + 1;
int y = i1 + 1;
cell.setValue("");
iRange.autoFit();
IRange range = sheet.getRange(excelColIndexToStr(y) + x + ":" + excelColIndexToStr(y) + x);
System.out.println(range);
Rectangle rect = com.grapecity.documents.excel.CellInfo.GetRangeBoundary(range);
System.out.println(rect.getWidth() + "\t" + rect.getHeight());
InputStream stream = new FileInputStream(new File("C:\\Users\\berylbai\\Downloads\\demo\\a118bda7-8f15-47d0-95e7-c3e8b1e82a82.png"));
sheet.getShapes().addPictureInPixel(stream, ImageType.PNG, rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
}
}
} |