How to add border for excel range in sheet

For eg I have data from A1:C5
I want to add border for that range in excel sheet. Can anyone please guide?

To add a border to a specific range in an Excel sheet using UiPath, you can follow these steps:

1.Use the “Excel Application Scope” activity to open your Excel file.

2.Within the scope, use the “Select Range” activity to select the range A1:C5.

3.After selecting the range, use the “Set Range Color” activity to set the border color for the selected range. You can configure the border style, thickness, and color as per your requirements.

4.Use the “Write Range” activity to save the changes to the Excel file.

@vnsatyasunil

Thanks for the information but for set range color activity, only color, range & sheet name options are there. Where to set thickness for border?

Hi,

Can you try the following sample using ClosedXML?

Sample20230930-1aL_Windows.zip (11.6 KB)

Using wb As New ClosedXML.Excel.XLWorkbook(filename)
    Dim sheet As ClosedXML.Excel.IXLWorksheet = wb.Worksheet(sheetName)
        With sheet.Range(strRange).Style
                   .Border.SetTopBorder(CLosedXML.Excel.XLBorderStyleValues.Thin)
                    .Border.SetBottomBorder(CLosedXML.Excel.XLBorderStyleValues.Thin)
                    .Border.SetLeftBorder(CLosedXML.Excel.XLBorderStyleValues.Thin)
                    .Border.SetRightBorder(CLosedXML.Excel.XLBorderStyleValues.Thin)
    End With
    wb.Save()
End Using

Regards,

1 Like

tried like this for invoke code activity error is throwing like
exception is thrown by target of an invocation

Hi,

Does the above sample work?
Can you share content of $exceptionDetails in Locals panel when error occurs?

Regards,

Hi
Try with this UiPath custom component

Demo

Hope this helps

Cheers @vnsatyasunil

1 Like

Yes, I experienced the same error