使用Delphi在Excel工作表的每一行中插入图像

我的Delphi 6程序需要在Excel表格的每一行上放置一个图像。 我可以插入一个图片到一个固定的位置,从另一个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; 

上面的代码工作正常,但我无法通过PictureTop和PictureLeft参数,使得每行的第二列有不同的图像?

如何获得特定单元格的顶部和左侧值? 还是有更好的方法来做到这一点?

请帮忙。

例如,如果你使用;

 ActiveSheet.Cells[2, 2].Select; ActiveSheet.Pictures.Insert(ImageFileName); 

那么你的图片顶部等于Cell [2,2]的顶部,图片的左边等于Cell [2,2]的左边