What I want to do is make the whole thing location independent. As it is, the paths to the full-size jpgs are hard-coded. I would like them to be located wherever the current working folder is.
int a = 1; Image fullSize = Image.FromFile(@"Screenshot.jpg"); Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback); Image thumb = fullSize.GetThumbnailImage(100, 71, myCallback, IntPtr.Zero); var picture = worksheet.Drawings.AddPicture(a.ToString(), thumb); picture.SetPosition(a-1 , 0, 6-1, 0); worksheet.Cells[a, 6].Hyperlink = new Uri("file://c:/Screenshot.jpg");
In sheet1.xml.rels, I found this:
<hyperlinks><hyperlink ref="F2" r:id="rId1"/></hyperlinks>
Moving the xls file to the desktop and opening it with Excel and clicking the hyperlink produces a “cannot open the specified file” error. Moving the jpg file to the desktop and then clicking the hyperlink works fine.
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="Screenshot3.jpg" TargetMode="External"/>
From novice to tech pro — start learning today.