我正在使用NOPI生成Excel文件,我使用以下代码将图像添加到Excel中:
//the drawing patriarch will hold the anchor and the master information
HSSFPatriarch patriarch = (HSSFPatriarch)sheet.CreateDrawingPatriarch();
//store the coordinates of which cell and where in the cell the image goes
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, 0, startRow, 1, startRow + 1);
//types are 0, 2, and 3. 0 resizes within the cell, 2 doesn't
anchor.AnchorType = 2;
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData(GetProductImage(manufacturerId, photoName));
//add the byte array and encode it for the excel file
int index = hssfworkbook.AddPicture(imageBytes, PictureType.JPEG);
HSSFPicture signaturePicture = (HSSFPicture)patriarch.CreatePicture(anchor, index);
这很好用但我现在还需要添加这些图像的链接,以便用户可以下载更大的版本。
任何人都能做到这一点吗?