@Amjad_Sahi, I’ve tried some stuff and the only thing that seems to work is modifying the shape’s width / x values and let the framework do the job, which doesn’t seem to be ideal, given it may be doing much more than what I need.
Some very basic maths that I’ve tried were:
var sheet = new Workbook(Main.class.getClassLoader().getResourceAsStream("Book1.xlsx")).getWorksheets()
.get(0);
var shape = sheet.getShapes().get(0);
System.out.println(String.format("shape.getLowerDeltaX() = %d", shape.getLowerDeltaX()));
double columnWidth = sheet.getCells().getColumnWidth(shape.getUpperLeftColumn());
System.out.println(String.format("shape.getUpperDeltaX() = %d", shape.getUpperDeltaX()));
System.out.println(String.format("columnWidth = %f", columnWidth));
System.out.println(String.format("shape.getLeft() = %d", shape.getLeft()));
For the spreadsheet attached, which has an image consuming a couple of pixels from the left and right cells, I should be able to get
Consuming left cells = getUpperDeltaX - columnWidth (which is giving ~1000)
Consuming right cells = getLowerDeltaX (which is giving 48)
Notice that both values doesn’t reflect a 1/2 pixels consumption to the left and to the right.
Another option that I’ve tried:
double totalWidth = 0;
for (int i = 0 ; i < shape.getUpperLeftColumn(); i++) {
totalWidth += sheet.getCells().getColumnWidth(i);
}
System.out.println(String.format("totalWidth = %f", totalWidth));
System.out.println(String.format("shape.getLeft() = %d", shape.getLeft()));
Assuming the total width, until the cell the image starts, would be close to the value of getLeft or maybe getX, although I am getting:
totalWidth = 124.861429
shape.getLeft() = 63
shape.getX() = 1007
Can you help me understanding what’s wrong on my math?
Book1.zip (20.6 KB)