We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to apply border to an image in a worksheet using XlsIO?

Platform: WinForms |
Control: XlsIO

Pictures in a worksheet can be formatted for a better view. XlsIO provides the feature to format pictures. This article explains on how to apply borders to an image using XlsIO.


A picture added to a worksheet is referred with the interface IPictureShape. The property Line in the interface allows to set borders settings, which is shown in the below code snippets.


            ExcelEngine excelEngine = new ExcelEngine();
            //Instantiate the excel application object.
            IApplication application = excelEngine.Excel;
            //The workbook is opened.
            IWorkbook workbook;
            string inputPath = GetFullTemplatePath("Sample.xlsx");
            workbook = application.Workbooks.Open(inputPath, ExcelOpenType.Automatic);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet worksheet = workbook.Worksheets[0];
            IPictureShape picShape = worksheet.Pictures.AddPicture(5, 3, @"..\..\Data\Img.png");
            picShape.Line.ForeColor = Color.Red;
            picShape.Line.DashStyle = ExcelShapeDashLineStyle.Solid;
            picShape.Line.Weight = 3;


            Dim excelEngine As ExcelEngine = New ExcelEngine()
            ‘Instantiate the excel application object.
            Dim application As IApplication = excelEngine.Excel
            'The workbook is opened.
            Dim workbook As IWorkbook
            Dim inputPath As String = GetFullTemplatePath("Sample.xlsx")
            workbook = application.Workbooks.Open(inputPath, ExcelOpenType.Automatic)
            'The first worksheet object in the worksheets collection is accessed.
            Dim worksheet As IWorksheet = workbook.Worksheets(0)
            Dim picShape As IPictureShape = worksheet.Pictures.AddPicture(5, 3, "..\..\Data\Img.png")
            picShape.Line.ForeColor = Color.Red
            picShape.Line.DashStyle = ExcelShapeDashLineStyle.Solid
            picShape.Line.Weight = 3


The sample illustrating this behavior can be downloaded here.



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile