本文整理汇总了Python中xlwt.Borders方法的典型用法代码示例。如果您正苦于以下问题:Python xlwt.Borders方法的具体用法?Python xlwt.Borders怎么用?Python xlwt.Borders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlwt
的用法示例。
在下文中一共展示了xlwt.Borders方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Borders [as 别名]
def set_style(name, height, bold=False):
style = xlwt.XFStyle() # 初始化样式
font = xlwt.Font() # 为样式创建字体
font.name = name # 'Times New Roman'
font.bold = bold
font.color_index = 4
font.height = height
# borders= xlwt.Borders()
# borders.left= 6
# borders.right= 6
# borders.top= 6
# borders.bottom= 6
style.font = font
# style.borders = borders
return style
示例2: set_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Borders [as 别名]
def set_style(name, height, bold=False):
# 设置字体
style = xlwt.XFStyle()
font = xlwt.Font()
font.name = name
font.bold = bold
font.color_index = 4
font.height = height
style.font = font
# 设置边框
borders = xlwt.Borders()
# 细实线:1,小粗实线:2,细虚线:3,中细虚线:4,大粗实线:5,双线:6,细点虚线:7
# 大粗虚线:8,细点划线:9,粗点划线:10,细双点划线:11,粗双点划线:12,斜点划线:13
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style.borders = borders
return style
# 写Excel
示例3: borders
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Borders [as 别名]
def borders(line=0x00, colour=0x40):
'''
@param line: cell线条格式
参照borders_map
@param colour: 线条颜色
查看_colour_map_text
'''
bds = xlwt.Borders()
bds.left = line
bds.right = line
bds.top = line
bds.bottom = line
bds.diag = line
bds.left_colour = colour
bds.right_colour = colour
bds.top_colour = colour
bds.bottom_colour = colour
bds.diag_colour = colour
return bds
示例4: set_excel_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Borders [as 别名]
def set_excel_style(name, height, bold=False):
"""Set excel style.
"""
style = xlwt.XFStyle() # 初始化样式
font = xlwt.Font() # 为样式创建字体
font.name = name # 例如'Times New Roman'
font.bold = bold
font.color_index = 4
font.height = height
if bold:
borders = xlwt.Borders()
borders.left = 6
borders.right = 6
borders.top = 6
borders.bottom = 6
style.borders = borders
style.font = font
return style
示例5: set_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Borders [as 别名]
def set_style(self):
'''
设置excel样式
'''
self.sheet.col(1).width = 256 * 30
self.sheet.col(2).width = 256 * 15
self.sheet.col(3).width = 256 * 20
self.sheet.col(4).width = 256 * 20
self.sheet.col(5).width = 256 * 60
self.sheet.col(6).width = 256 * 15
self.sheet.col(9).width = 256 * 15
self.sheet.row(0).height_mismatch = True
self.sheet.row(0).height = 20 * 20
self.basic_style = xlwt.XFStyle()
al = xlwt.Alignment()
# 垂直对齐
al.horz = al.HORZ_CENTER
# 水平对齐
al.vert = al.VERT_CENTER
# 换行
al.wrap = al.WRAP_AT_RIGHT
# 设置边框
borders = xlwt.Borders()
borders.left = 6
borders.right = 6
borders.top = 6
borders.bottom = 6
self.basic_style.alignment = al
self.basic_style.borders = borders