Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top