How to add border to Excel rows

Hi, I’m trying to add a border to a particular range in excel while writing them. I’m quite new to Uipath and C#. I managed to find the below resource, but I’m not quite sure how I can apply this logic in UiPath.

How can a border be set around multiple cells in excel using C#.

Please guide me.

Thank you

Please read this,

I know, That’s why I attached the resource stating how we can assign the border in Excel using C#.

Here is the link:

How can a border be set around multiple cells in excel using C#.

Any Ideas how can I incorporate it into my flow?

Please download both files(xaml and macro file),
Excel save.xaml (8.3 KB)Set Border.xlsx (9.0 KB)

save Set Border.xlsx file as Set Border.xlsm
and run.

hi, when I’m opening Set Border after changing its extension I’m getting an error saying file may be corrupted.

Ok… No worries.

  1. please create excel as *.xlsm,
  2. go to developer tab,
  3. click on macros and create new macro and
  4. Paste below code, save it and run it

Sub setBorder()
Dim rang As Range
Set rang = Worksheets(“Sheet1”).Range(“A1:B4”)
With rang.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
End Sub

Regards,
Pankaj

Hello @Pankaj.Patil,
thank you, But what if we aren’t allowed to run the macro on the target machine? I want something that can be written like set colour activity for cell or range.

Any guesses there?

Thanks :slight_smile:

Hello @RishiVC1,

It’s enough simple. please download xaml and excel files below,
Report.xlsx (7.8 KB)
Main.xaml (7.3 KB)

Regards,
Pankaj

what I meant that there should be an equivalent solution for setting up borders as compared to setting colour.

@RishiVC1

Use this activity it has set border activity in it.

2 Likes

Hi @mitesh_parmar.

Thank you.

1 Like

hi thank you for the activity! system will prompt that excel found is found, do i want to overwrite it. as there are a few worksheets in an excel file that i need to draw borders. anyway to remove the prompting?

sorry the one i tried out was from below: (didn’t work though)
Capture

1 Like

Hi @winnie_toh ,

Try this

Regards
Balamurugan.S

dear @Balupad14 thank you for your help!
in the end, i created table instead, and there will be default borders and colors. so it resolved my needs. thanks again!

1 Like