参数说明:
public XSSFClientAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) {
this.anchorType = AnchorType.MOVE_AND_RESIZE;
this.cell1 = Factory.newInstance();
this.cell1.setCol(col1);
this.cell1.setColOff((long)dx1);
this.cell1.setRow(row1);
this.cell1.setRowOff((long)dy1);
this.cell2 = Factory.newInstance();
this.cell2.setCol(col2);
this.cell2.setColOff((long)dx2);
this.cell2.setRow(row2);
this.cell2.setRowOff((long)dy2);
}
可以看到一共有8个参数,前四个为图片距离单元格left,top,right,bottom四个方向的像素距离
后四个为图片所在单元格区间所在的行数和列数
实例:
这里主要对后四个参数进行实验
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 255, 255,14, 2, 18, 13);
可以看到我的参数中col1和col2分别为14和18, row1和row2分别为2和13,代表图片起始列距离左侧有14列距离,图片结束列距离左侧有18列距离.图片所占列数为4.行数同理为距离上方的行数距离.
效果图: