码迷,mamicode.com
首页 > 其他好文 > 详细

AX2012 引用NOPI 添加图片到EXCEL

时间:2015-10-06 14:09:27      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:

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();这句话一定不要,这是用图片原始大小来显示
    }

}

  

AX2012 引用NOPI 添加图片到EXCEL

标签:

原文地址:http://www.cnblogs.com/sambai/p/4857061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!