问题描述
我已将选定的图像文件插入到合并的单元格区域中。图像会自动重新调整大小
以适应单元格(保持纵横比)。一切运作良好,但我遇到了问题。
我发现包含图像的合并单元在整个单元格中的宽度和高度各不相同,即使在相同的单元格上也是如此。
我不想仔细检查每个单元格并找出每个单元格的宽度和高度,并且每次输入相应的
值,(可能需要一个时间) ay)。
如果有办法编写代码以便将图像大小调整为
大小(它实际上是一组合并的单元格),那将会有所帮助。它被放入。
基本上我需要保持图像文件的宽高比,并填充目标单元格,而不超过
它们的边界。
I have inserts the selected image file into a merged range of cells. The images are automatically re-sized to fit into the cell (aspect ratio maintained). Everything works well, but I ran into a problem.
There are about many cells, I found out that the merged cells to contain the images vary in width and height throughout the cells, even on the same cells.
I do not want to go through every one and figure out the width and height for each cell and type in the corresponding values for every time, (it might take me one day).
What would be helpful is if there were a way to write the code so that the image is resized to the size of the cell (it is actually a merged set of cells), that it is being placed into.
Essentially I need to maintain the aspect ratio of the image file, and fill the target cell(s) without exceeding their boundaries.
推荐答案
当保留Image ApectRatio并且您尝试设置图像的高度和宽度时,最后一个代码命令优先。例如,如果您将图像高度设置为单元格高度然后图像的宽度改变相同的比率。如果你然后
设置图像的宽度,那么图像的高度将改变相同的比率。
When Image ApectRatio is retained and you attempt to set the Height and Width of the image then the last code command takes precedence. eg. if you set the image Height to the cell Height then the Width of the image changes by the same ratio. If you then set the Width of the image then the Height of the image will changes by the same ratio.
在首次发布后添加了编辑。
如果您想调整图片大小以使其保留在单元格内,但允许高度或宽度更小比后面的细胞更改图像的高度和宽度以尝试匹配单元格的高度和宽度,然后需要
来使用if语句来确定图像的高度或宽度是否超过高度或宽度单元格并将该尺寸重置回单元格尺寸,然后另一个图像尺寸将自动小于单元格。
If you want to size the image so that it remains inside the cell but allowing either the Height or Width to be smaller than the cell then after changing the Height and Width of the image in an attempt to match the Height and Width of the cell you then need to use if statements to determine if either the height or the Width of the image exceeds the Height or Width of the cell and reset that dimension back to the cell dimension and then the other image dimension will automatically be smaller than the cell.
这篇关于将图像调整为单词中指定的选定单元格的尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!