string filename = ComMethod.ObjToString(Table1.Rows[index]["files"]);    

  if (!string.IsNullOrEmpty(filename))                  

   {                       

  string path = Server.MapPath(ConfigurationManager.AppSettings["ArtworkFile"]);                     

    string readpath = path + filename;                       

  FileInfo file = new System.IO.FileInfo(readpath);                        

if (!file.Exists)                        

{                            

ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('" + readpath + ",该文档不存在!');</script>");                    

     }

                   

     byte[] bytes = System.IO.File.ReadAllBytes(readpath);                         //byte[] bytes = System.IO.File.ReadAllBytes("E:\\ttt\\Chrysanthemum.jpg");                         int pictureIdx = hssfworkbook.AddPicture(bytes, PictureType.JPEG);

                        // Create the drawing patriarch.  This is the top level container for all shapes.                         HSSFPatriarch patriarch = (HSSFPatriarch)excelSheet.CreateDrawingPatriarch();

                        //add a picture,hssfclientanchor包含8个参数,其中,后面四个参数分别指嵌入图片的位置                         HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 1023, 0, (short)(2 + tablesize.Rows.Count), 5, 11, (short)(startrow + deletecount1));

                        patriarch.CreatePicture(anchor, pictureIdx);                     }

相关文章:

  • 2021-10-17
  • 2021-09-29
  • 2021-06-08
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-10-24
猜你喜欢
  • 2021-11-25
  • 2021-07-17
  • 2021-08-29
  • 2021-12-31
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案