Hi,
We are very sorry for the delay in response.
The Scale Height and Scale Width of MsExcel are linked to the original Height and Width of the picture, therefore modifying these values will modify the height and width of the picture respectively. DsExcel exposes the methods setWidth, setHeight, setWidthInPixel, and setHeightInPixel methods in the IShape interface which can be utilized to scale the image. Refer to the below code snippet to scale height and width.
private void scaleWidthInPixel(IShape shape, double scale, double initialWidth) {
double currentWidth = 0;
if(initialWidth == -1) {
currentWidth = shape.getWidthInPixel();
}
else {
currentWidth = initialWidth;
}
double scaledWidth = currentWidth * scale / 100;
shape.setWidthInPixel(scaledWidth);
}
private void scaleHeightInPixel(IShape shape, double scale, double initialHeight) {
double currentHeight = 0;
if(initialHeight == -1) {
currentHeight = shape.getHeightInPixel();
}
else {
currentHeight = initialHeight;
}
double scaledHeight = currentHeight * scale / 100;
shape.setHeightInPixel(scaledHeight);
}
The Lock Aspect Ratio will help to scale the height and width together which again can be achieved through the width and height mutators of the IShape interface. Please refer to the code snippet below:
private static void scaleDimensions(IShape shape, double scale, double initialWidth, double initialHeight) {
scaleWidthInPixel(shape, scale, initialWidth);
scaleHeightInPixel(shape, scale, initialHeight);
}
The Relative to original picture size manipulates the scale of the image concerning the original size of the image, when this checkbox is unchecked, the image scales according to the current dimensions rather than the initial dimensions, the arguments - initialWidth and initialHeight present in the above functions handles the same.
You can further refer to the attached sample that implements the above code snippets and generates the scaled images.
Please note that the scaling visible in MsExcel will be different for different screen resolutions as per the behavior of MsExcel with System Scaling and Layout settings. It can also be affected by other factors, which is internally controlled by MsExcel
Attachment: scale_Updated.zip
Best Regards,
Kartik