Is there any option to add thick border in Excel using xlsxwriter?
I'm writing a border between a range using conditional format.
Is there any option to add thick border in Excel using xlsxwriter?
I'm writing a border between a range using conditional format.
Is there any option to add thick border in Excel using xlsxwriter?
You can use a cell format with a border style 2 or 5 for this. See the weight column in the Format set_border() method:
import xlsxwriter
workbook = xlsxwriter.Workbook('borders.xlsx')
worksheet = workbook.add_worksheet()
format1 = workbook.add_format({'border': 1})
format2 = workbook.add_format({'border': 2})
format3 = workbook.add_format({'border': 5})
worksheet.write('B3', 'Border 1', format1)
worksheet.write('B6', 'Border 2', format2)
worksheet.write('B9', 'Border 5', format3)
workbook.close()
Output:
Note however, as far as I know Excel doesn't support/allow thicker borders in conditional formats. As far as I can see the only weight allowed, via the dialog, is 1, i.e., standard thickness.
Also note, there is no direct way in XlsxWriter to apply a border around a range. You will need to apply the appropriate border formats (8+ formats) to all the cells at the edges of the range. This is what Excel does, it is just hidden behind the GUI.
set_border_color()
or border_color
as a parameter: xlsxwriter.readthedocs.io/format.html#format-set-border-color –
Turnstone © 2022 - 2024 — McMap. All rights reserved.