shevski
shevski

Reputation: 1022

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

Upvotes: 3

Views: 8641

Answers (2)

alecxe
alecxe

Reputation: 473873

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.

Upvotes: 3

John Y
John Y

Reputation: 14529

You don't set the border width separately; it's tied to the border style index. See the docs. For example, try index 2 or 5 for continuous border of weight 2 or 3, respectively.

Upvotes: 2

Related Questions