效果
代码:
if (j > 0){ICell cellj = null;cellj = headerRow.CreateCell(2 + j);cellj.SetCellValue("");cellj.CellStyle = commonCellStyle;mySheet.SetColumnWidth(2 + j, 35 * 256);if (j == imgs.Count() - 1){maxNumber = imgs.Count();mySheet.AddMergedRegion(new CellRangeAddress(0, 0, 2, 2 + j));}} //下载网络图片#region MyRegionvar path = imgs[j].Split("upload");string imgpath = "wwwroot/upload" + path[1];byte[] bytes = System.IO.File.ReadAllBytes(imgpath);int index = 0;if (imgs[j].Contains(".jpg")){index = book.AddPicture(bytes, PictureType.JPEG);}else if (imgs[j].Contains(".png")){index = book.AddPicture(bytes, PictureType.PNG);}var rowTemp2 = rowTemp.CreateCell(2 + j);rowTemp2.CellStyle = commonCellStyle;var clientAnchor = mySheet.Workbook.GetCreationHelper().CreateClientAnchor();clientAnchor.Row1 = i + 1;clientAnchor.Col1 = 2 + j;clientAnchor.Dx1 = i + 1;clientAnchor.Dy1 = 2 + j;var picture = (mySheet.DrawingPatriarch ?? mySheet.CreateDrawingPatriarch()).CreatePicture(clientAnchor, index);picture.Resize(0.6, 1.0);#endregion