使用 Delphi 在 Excel 工作表的每一行插入图像
我的 Delphi 6 程序需要在 Excel 工作表的每一行上放置一个图像。 我可以将图片插入到固定位置,其中包含我从另一篇文章中读到的内容。
procedure insertImages(ActiveSheet: OleVariant; ImageFilePath: String; ImageHeight, PictureTop, PictureLeft: Integer);
var
Picture: OleVariant;
begin
try
Picture := ActiveSheet.Pictures.Insert(ImageFilePath);
Picture.Width := ImageHeight * Picture.Width /Picture.Height;
Picture.Height := ImageHeight;
Picture.ShapeRange.Left := PictureLeft;
Picture.ShapeRange.Top := PictureTop;
Picture.Placement := xlMove;
except
end; //try
end; //insertImages;
上面的代码工作正常,但我在传递 PictureTop 和 PictureLeft 参数时遇到问题,因此每行的第二列上有不同的图像?
如何获取特定单元格的顶部和左侧值? 或者有更好的方法来做到这一点吗?
请帮忙。
My Delphi 6 program need to place an image on each row of my of Excel Sheet.
I could insert a picture to a fixed position with something I read from another post.
procedure insertImages(ActiveSheet: OleVariant; ImageFilePath: String; ImageHeight, PictureTop, PictureLeft: Integer);
var
Picture: OleVariant;
begin
try
Picture := ActiveSheet.Pictures.Insert(ImageFilePath);
Picture.Width := ImageHeight * Picture.Width /Picture.Height;
Picture.Height := ImageHeight;
Picture.ShapeRange.Left := PictureLeft;
Picture.ShapeRange.Top := PictureTop;
Picture.Placement := xlMove;
except
end; //try
end; //insertImages;
The above code works fine, but I having trouble passing the PictureTop and PictureLeft parameter to make it so there is different image on the 2nd column of each row?
How can I get the Top and Left value for a specific cell?
Or is there a better way to do this?
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,如果您使用;
那么图片的顶部等于 Cell[2, 2] 的顶部,图片的左侧等于 Cell[2, 2] 的左侧
For example If you use;
then your picture's top equals top of Cell[2, 2] and picture's left equals left of Cell[2, 2]