使用EPPlus将超链接添加到引用文档中另一个工作表的单元格中的图像

在EPPlus上需要一些帮助,我插入一个图像,并希望图像超链接到不同的工作表(内容列表)。 AddImage函数接受超链接属性的Uri对象,但不接受任何单元格值。

这是我的代码

private static void AddImage(ExcelWorksheet ws, int columnIndex, int rowIndex, string filePath,int offset,string optionalHyperLinkURL = "") { Bitmap image = new Bitmap(filePath); ExcelPicture picture = null; if (image != null) { if (optionalHyperLinkURL != ""){ // it's crashing here because I can't pass in [XXXXX.xlsx]'TOC!A1' as the hyperlink since it's not a valid URL picture = ws.Drawings.AddPicture("pic00", image, new Uri(optionalHyperLinkURL)); } else { picture = ws.Drawings.AddPicture("pic00", image); } picture.From.Column = columnIndex; picture.From.Row = rowIndex; picture.From.ColumnOff = Pixel2MTU(offset); //Two pixel space for better alignment picture.From.RowOff = Pixel2MTU(2);//Two pixel space for better alignment picture.SetSize(386, 138); } }