标签:
void AddPieChart(int rowNum = 4) { System.Byte[] bytes; fileName _fileName; NPOI.HSSF.UserModel.HSSFPatriarch patriarch; NPOI.HSSF.UserModel.HSSFClientAnchor anchor; NPOI.HSSF.UserModel.HSSFPicture pict; int png; _fileName =@"C:\lmlogo.png"; if(_fileName) bytes = System.IO.File::ReadAllBytes(_fileName); if (bytes) { png = hssfworkbook.AddPicture(bytes,NPOI.SS.UserModel.PictureType::PNG); patriarch = sheet.CreateDrawingPatriarch(); anchor = new NPOI.HSSF.UserModel.HSSFClientAnchor( 0, 0, 1000, 0, 0, 0 , rowNum, 1); //##处理照片位置,【图片左上角为(col, row)第row+1行col+1列,右下角为( col +1, row +1)第 col +1+1行row +1+1列,宽为100,高为50 pict = patriarch.CreatePicture(anchor, png); // pict.Resize();这句话一定不要,这是用图片原始大小来显示 } }
标签:
原文地址:http://www.cnblogs.com/sambai/p/4857061.html