zoukankan      html  css  js  c++  java
  • NPOI 导出Excel图片 (网络)

        导出网络图片,需要将网络图片下载到本地或者内存流中,建议下载的时候使用缩略图;

        高清图片效率慢;

                Uri uri = new Uri(imgPath); //imgPath :网络图片地址

                WebRequest webRequest = WebRequest.Create(uri);

                using (WebResponse webResponse = webRequest.GetResponse())

                {

                    Bitmap bitmap = new Bitmap(webResponse.GetResponseStream());

                    using (MemoryStream ms = new MemoryStream())

                    {

                        bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                        byte[] bytes = ms.ToArray();

                        int pictureIdx = workbook.AddPicture(bytes, NPOI.SS.UserModel.PictureType.PNG);  //添加图片

                        HSSFPatriarch patriarch = (HSSFPatriarch)sheet.CreateDrawingPatriarch();

                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 240, col, row, col + 1, row + 1);

                        //图片位置,图片左上角为(col, row)

                        HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);

                        pict.Resize(); //用图片原始大小来显示

                    }

                }

  • 相关阅读:
    Auto Complete with Redis
    老男孩 movie
    e人e本
    邀请大家使用dropbox
    mac Espresso
    it网站
    To Trie or not to Trie – a comparison of efficient data structures
    [转载]提高Python程序的运行速度_李小红_新浪博客
    TSTTernary Search TreeCreating An English Dictionary for lookup and spell checking | CracktheInterview
    平衡二叉搜索树
  • 原文地址:https://www.cnblogs.com/peasana/p/5242420.html
Copyright © 2011-2022 走看看