nopi export excel with pictures

HSSFWorkbook hssfworkbook = new HSSFWorkbook();
var sheet1 = hssfworkbook.CreateSheet("第一个Sheet");

//图片的操作
byte[] bytes = System.IO.File.ReadAllBytes(@"D:\test.jpg");  
int pictureIdx = hssfworkbook.AddPicture(bytes, PictureType.JPEG);  
HSSFPatriarch patriarch = (HSSFPatriarch)sheet1.CreateDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, 0, 0, 3, 3);
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);

//保存
FileStream file = new FileStream("D:/test.xls", FileMode.Create);
hssfworkbook.Write(file);
file.Close();

  If you can not read HSSFClientAnchor method

 Reference https://www.cnblogs.com/1175429393wljblog/p/9809868.html

This is a very detailed description of this method, I do not write here! If you mouse over to see it to understand not to ask, read on to see the access link, not to ask the

Guess you like

Origin www.cnblogs.com/sajiao/p/11263249.html