4

Right now I am coloring a cell in openpyxl in Python by importing this:

from openpyxl.styles import Color, PatternFill, Font, Border

and then doing this:

myFill = PatternFill(start_color='FF0000', 
                     end_color='FF0000', 
                     fill_type = 'solid')

ws.cell(row=row,column=column).fill = myFill

Where "ws" is a worksheet, row and column are a particular row and column, etc.

This works great, but adjacent cells are totally filled and it's hard to distinguish one cell from another without grid lines. Is there any simple way to adjust this code so that the grid lines remain but the color is still there?

secretagentmango
  • 619
  • 2
  • 10
  • 17

1 Answers1

0

I just ended up drawing a border around each cell. I used this for reference:

Applying borders to a cell in OpenPyxl

My initial concern was that I would have to draw each side of the box individually and I didn't want my code to drone on, but creating one full border and then applying it was fine.

secretagentmango
  • 619
  • 2
  • 10
  • 17