How to apply border to an image in a worksheet using 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; 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