I've mananged to successfully use COM to open up Microsoft Excel and insert an image for each row of data based on the filename retrieved from my database.
I am using code found below, which I found on Google:
The problem is that the AddPicture funtion uses X,Y coordinates to place the picture. So it's hard and messy to place the picture exactly in the cell that you want.
string filename = "C:\\PHOTOS\\" + reader["photo_no"] + ".JPG";
FileInfo fi = new FileInfo(filename);
Microsoft.Office.Core.MsoTriState.msoCTrue, 1, 200, 40, 50);
Is there is a function where I can place the picture right into the exact cell by using the range function?
Edit: I would like to point out there ideally I would like to use this code:
But, the problem with this code is that YOU CANNOT SPECIFIY the image size. So if your original JPG is 1000x1000 then that's how big it'll look once you pasted into Excel.
ThisWorkBook = ThisApplication.Workbooks.Open(_stFileName,missing,missing,5,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing,missing);
Excel.Worksheet ThisSheet = (Excel.Worksheet)ThisWorkBook.Sheets;
Excel.Range oRange = (Excel.Range)ThisSheet.Cells[10,1];
Image oImage = Image.FromFile(_stLOGO);
Thanks again. Hope this helps a few others out there.