Method
Border settings
`Index` can be one of the following `XlBordersIndex` constants: xlDiagonalDown、xlDiagonalUp、xlEdgeBottom、xlEdgeLeft、xlEdgeRight、xlEdgeTop、xlInsideHorizontal or xlInsideVertical。
#xlwings API
sht.api.Range(‘B2’).CurrentRegion.Borders.LineStyle=xw.constants.LineStyle.xlContinuous
#sht.api.Range(‘B2’).CurrentRegion.Borders.ColorIndex=3
#sht.api.Range(‘B2’).CurrentRegion.Borders.Weight=xw.constants.BorderWeight.xlThick
Sample Code
#Cell comments
import xlwings as xw #Import the xlwings package
app=xw.App()
bk=app.books.active #Get the active workbook
sht=bk.sheets.active #Get the active worksheet
#xlwings API
sht.api.Range('B2').CurrentRegion.Borders.LineStyle=xw.constants.LineStyle.xlContinuous
sht.api.Range('B2').CurrentRegion.Borders.ColorIndex=3
sht.api.Range('B2').CurrentRegion.Borders.Weight=xw.constants.BorderWeight.xlThick
#bk.close()
#app.kill()

Leave a Reply