1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > c# 导出excel之插入图片

c# 导出excel之插入图片

时间:2023-03-28 12:08:49

相关推荐

c# 导出excel之插入图片

效果

代码:

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。