1

I am trying to change box border of some excell cells to "Thick Box Border". I am using django 1.9.5 and python 2.7.5 and xlsxwriter for excell.

import xlsxwriter

workbook = xlsxwriter.Workbook('bordertest.xlsx')
worksheet = workbook.add_worksheet()
format = workbook.add_format({'border': 2})
worksheet.write('B3', 'Border2', format)

This is working for one cell. But i want to apply thick box border around some group of cells like below. I couldn't figure it out. I want to apply thick border to rectangle block of cells between B4-G4 & B8-G8. Between red dots the lines will be bold. But cells in the red dotted rectangle area, will be normal border. So different color group of cells will be seperated with thick border.

enter image description here

ivbtar
  • 799
  • 11
  • 29

1 Answers1

2

Have you tried to loop through it somehow?

As far as I know conditional formatting gives you the ability to use cell ranges:

worksheet.conditional_format(cells_range, {'type': 'cell',
                                 'criteria': '=',
                                 'value': 'border2', 'format': format})
iSerd
  • 178
  • 1
  • 8
  • Hi, as i understand conditional_format is working cell by cell.If i do this, all cells are wrapped with thick box border. There is a group of cells, and i want to outline these group of cells with thick border. Cells inside this group will not be outlined. If you look at above example only outer edges of yellow rectangle will be thick border. The cells inside will not be thick box border. – ivbtar Jan 02 '19 at 13:25
  • so the workaround for this would be to format borders of outer cells which is basically given the border thickness to the left side of the left outer cells and right side of right outer cells as well as bottom side of bottom outer cells and top side of top outer cells... which would give you 4 different conditional formats to add – iSerd Jan 02 '19 at 15:03