Anyone know why this is not adding borders to my sheet?

        thick = Side(border_style="thick", color='FF0707')
        ws['F1'].border = Border(top=thick, left=thick, right=thick, bottom=thick)
        for row in ws['A1:D10']:
            for cell in row:
                cell.border = Border(top=thick, left=thick, right=thick, bottom=thick)

Recommended Answers

All 4 Replies

How about some context? Perhaps you could post a full, but stripped down example that we could try to run. Based on what little you posted I really have no idea what you are doing or what you are doing it with.

i stated the tag openpyxl, and the example is a full example to add borders to cell. i havent explain much because the tag and code can only be one thing, but ill try to give a better explanation.

Using openpyxl im trying to set borders to my excell spreedsheet, this is what iv got so far

thick = Side(border_style="thick", color='FF0707')
        ws['F1'].border = Border(top=thick, left=thick, right=thick, bottom=thick)
        for row in ws['A1:D10']:
            for cell in row:
                cell.border = Border(top=thick, left=thick, right=thick, bottom=thick)

this is the part of my code where i create the file

      wb = openpyxl.Workbook()
      ws = wb.active
      wb.create_sheet("General Form")
      ws = wb['General Form'] 

      thick = Side(border_style="thick", color='FF0707')
            ws['F1'].border = Border(top=thick, left=thick, right=thick, bottom=thick)
            for row in ws['A1:D10']:
                for cell in row:
                    cell.border = Border(top=thick, left=thick, right=thick, bottom=thick)


  wb.save(os.path.join('Reports', filename_report))

It is possible that those are functions/methods exposed by openpyxl. It is also possible that they would be available as coded if the import were written as

from openpyxl import *

It's also possible they are custom methods coed by the OP but not included here. We'll never know since the OP did not include the full code of the example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.