我希望有人可以帮助我,因为我遗憾地无法为自己找到这个。
我正在尝试使用openpyxl 2.3.3和python 3.4在单元格周围放置一个细边框。我有以下代码:
from openpyxl.styles import Border
ws.cell('A1').border = Border(top = Side(border_style='thin', color='FF000000'),
right = Side(border_style='thin', color='FF000000'),
bottom = Side(border_style='thin', color='FF000000'),
left = Side(border_style='thin', color='FF000000'))
奇怪的是,这会引发以下错误:
NameError: name 'Side' is not defined
我在这里查看了官方文档:
http://openpyxl.readthedocs.org/en/2.4/styles.html http://openpyxl.readthedocs.org/en/2.4/_modules/openpyxl/styles/borders.html
我也看了下面没有运气的文章:
https://bitbucket.org/openpyxl/openpyxl/issues/365/styling-merged-cells-isnt-working
Applying borders to a cell in OpenPyxl
Apply borders to all cells in a range with openpyxl
Apply Border To Range Of Cells Using Openpyxl
有人能帮助我吗?
提前致谢,
埃蒙
答案 0 :(得分:6)
您尚未导入Side
对象。
from openpyxl.styles import Border, Side