Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xlsxwriter can't set border width

I'm trying to set the cell's border width in an Excel file using XlsxWriter, but I could not find a call for it in the API. I'm looking for a solution similar to using this menu:

enter image description here

like image 846
shevski Avatar asked Dec 30 '25 18:12

shevski


1 Answers

Cell border can be changed by changing border style via set_border on a format class:

from xlsxwriter.workbook import Workbook

workbook = Workbook('output.xlsx')
worksheet = workbook.add_worksheet()

format = workbook.add_format()
format.set_border(style=1)

worksheet.write('A1', "Hello, world!", format=format)

workbook.close()

Also see documentation.

UPD: I think you cannot currently change cell border width directly from xlsxwriter.

Hope that helps.

like image 195
alecxe Avatar answered Jan 02 '26 07:01

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!