Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java poi shiftRows可调整大小且不移动图像_Java_Apache_Apache Poi_Xlsx - Fatal编程技术网

Java poi shiftRows可调整大小且不移动图像

Java poi shiftRows可调整大小且不移动图像,java,apache,apache-poi,xlsx,Java,Apache,Apache Poi,Xlsx,我正在使用POI,我想在xlsx中插入一些行。在这个文件中,我在一个表中有一些图像。通过执行以下操作移动行时: sheet.shiftRows(30, sheet.getLastRowNum(), 10, true, true); 某些图像位于错误的位置,并且已调整大小 如何在不调整图像大小的情况下一次移动所有项目并将其放在正确的位置?遇到了这个问题,这段代码对我很有用 基本上,需要做的是更改图像的定位,以反映新的行索引 XSSFDrawing drawings = mainSheet.cre

我正在使用POI,我想在xlsx中插入一些行。在这个文件中,我在一个表中有一些图像。通过执行以下操作移动行时:

sheet.shiftRows(30, sheet.getLastRowNum(), 10, true, true);
某些图像位于错误的位置,并且已调整大小


如何在不调整图像大小的情况下一次移动所有项目并将其放在正确的位置?

遇到了这个问题,这段代码对我很有用 基本上,需要做的是更改图像的定位,以反映新的行索引

XSSFDrawing drawings = mainSheet.createDrawingPatriarch();
for(XSSFShape shape : drawings.getShapes()){
    if(shape instanceof Picture){
        XSSFPicture picture = (XSSFPicture) shape;
        XSSFClientAnchor anchor = picture.getClientAnchor();
        int row1 = anchor.getRow1();
        if (row1 >= 30 && row1 <= mainSheet.getLastRowNum()) {
            int row2 = anchor.getRow2();
            anchor.setRow1(row1 + 10);
            anchor.setRow2(row2 + 10);
        }
     }
 }
XSSFDrawing-drawing-drawings=mainSheet.createdrawingparhical();
对于(XSSFShape:drawings.getShapes()){
if(图片的形状实例){
XSSFPicture图片=(XSSFPicture)形状;
XSSFClientAnchor anchor=picture.getClientAnchor();
int row1=anchor.getRow1();

if(row1>=30&&row1 shiftRows可能与图像没有太大关系,因为这是一个不太常见/更高级的用例。如果您想要另一组耳朵,请在POI邮件列表上询问这个问题。是的……我最终使用了样式等的复制方法。然后,我“手动”复制图像