How to add all border to the Excel cells

Hi Guys.I need to add all border to the excel cells.Can anyone help me with this.Thanks in advance

@sandhyak9

The possible solutions(to be used based on business scenario) that i could think of are-

  1. Using Template file
  • Create an excel file as template and add all the formatting you want.
  • Add steps in BOT to create a new excel file in the required location as a copy of the template file specified above.
  • Use write range activity to enter data into the file. Write range will write only the data into the files and do not change the original format.
  1. Formatting Excel
  • Open excel file.
  • Do ctrl+a.
  • Got to Home tab and then click the Border > All Borders . See screen shot below
  • Save the file and close
    Capture

Hope this is helpful!
If this resolves your issue, please mark it as solution so that people facing similar issues can directly navigated to answer.

Hi @sandhyak9,

First select the range of cells using “Select Range” activity or using “Ctrl+A” hotkey. Then you can add all border by sending the hotkey “Alt+Shift+b+h+a” inside an excel application scope.
allborder

Warm regards,
Nimin

3 Likes

control +b is not working for bold text.Any other way is there?

For Border write the below code in the Invoke Code Acitivity

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range

excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb = excel.Workbooks.Open(“File Path”)
excel.Visible=False
ws=CType(wb.Sheets(“SheetName”),Microsoft.Office.Interop.Excel.Worksheet)
ws.Range(“A1:C1”).Cells.Borders.LineStyle = XlLineStyle.xlContinuous

Bold

ws.Range(“A1:C1”).Font.Bold = True

wb.Save
wb.Close

3 Likes

Hi,
This activity sets border to cell or cell range.

Regards
Balamurugan.S

2 Likes

Hi @Ilayaraja I am trying your code but tell me --> “XlLineStyle” undeclared. How can i do that?

Thanks in advance

@salvatore.quimi

Try Microsoft.Office.Interop.Excel.XlLineStyle

Regards
Ilayaraja

This is excellent , Thanks for these short cuts , where can I find more of these?