Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
755
Excel Export Image
posted

Hi

 

is it possible to add Images to an ExcelWorkbook?

how can i do this ?

  • 30945
    Verified Answer
    Offline posted

    Hello,

     

    You can add an image to your Workbook with the following C# code:

                Workbook workbook = new Workbook();
    
                Worksheet ws1 = workbook.Worksheets.Add(<Sheet name>);
    
                System.Drawing.Image image = new System.Drawing.Bitmap(<Image path>);
    
                WorksheetImage imageShape = new WorksheetImage(image);
    
    
                WorksheetCell cellA1 = ws1.Rows[0].Cells[0];
    
                imageShape.TopLeftCornerCell = cellA1;
                imageShape.TopLeftCornerPosition = new PointF(0.0F, 0.0F);
    
                imageShape.BottomRightCornerCell = cellA1;
                imageShape.BottomRightCornerPosition = new PointF(100.0F, 100.0F);
    
                ws1.Shapes.Add(imageShape);
    
                workbook.Save("test.xls");
    

     

    You can find more detailed information about adding an image to a Worksheet here: http://help.infragistics.com/Help/NetAdvantage/ASPNET/2010.2/CLR4.0/html/ExcelEngine_Add_an_Image_to_a_Worksheet.html

     

    If you need any further assistance please do not hesitate to ask.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support