Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set border using Python xlwings

Is there a way to set border lines for an Excel file from Python using xlwings? I was looking at the documentation but cannot figure out.

I want to create a file like this using xlwings enter image description here

like image 604
E.K. Avatar asked Aug 30 '25 18:08

E.K.


1 Answers

As far as I know, this isn't a feature that's built into xlwings at this point. However, you can use the lower level pywin32 functions (with caveats) as described in the xlwings docs here.

Here's a brief example of how to set borders on a single cell using this method:

rng = xw.Range('A1').xl_range
for border_id in xrange(7,13):
    rng.Borders(border_id).LineStyle=1
    rng.Borders(border_id).Weight=2
like image 169
schoolie Avatar answered Sep 02 '25 07:09

schoolie