for (POIXMLDocumentPart dr : sheet.getRelations()) {
if (dr instanceof XSSFDrawing) {
XSSFDrawing drawing = (XSSFDrawing) dr;
List<XSSFShape> shapes = drawing.getShapes();
for (XSSFShape shape : shapes) {
XSSFPicture pic = (XSSFPicture) shape;
//可能变形
//XSSFClientAnchor anchor = pic.getPreferredSize()
XSSFClientAnchor anchor = pic.getClientAnchor();
anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE);
anchor.setRow1(writeRownum - writeConfigure.getWriteRownum() + anchor.getRow1());
anchor.setRow2(writeRownum - writeConfigure.getWriteRownum() + anchor.getRow2());
}
}
}
找时间整理下