本文整理汇总了Python中xlwt.Font方法的典型用法代码示例。如果您正苦于以下问题:Python xlwt.Font方法的具体用法?Python xlwt.Font怎么用?Python xlwt.Font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlwt
的用法示例。
在下文中一共展示了xlwt.Font方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [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_excel_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [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
示例3: set_style
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [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
示例4: export2xls
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [as 别名]
def export2xls(self):
import xlwt
font0 = xlwt.Font()
font0.bold = True
font0.height = 300
print((font0.height))
style0 = xlwt.XFStyle()
style0.font = font0
style1 = xlwt.XFStyle()
style1.num_format_str = 'D-MMM-YY'
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 'Test', style0)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
wb.save('datasheet.xls')
os.system("gnumeric datasheet.xls")
示例5: create_simple_xls
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [as 别名]
def create_simple_xls(self, **kw):
font0 = xlwt.Font()
font0.name = 'Times New Roman'
font0.colour_index = 2
font0.bold = True
style0 = xlwt.XFStyle()
style0.font = font0
style1 = xlwt.XFStyle()
style1.num_format_str = 'D-MMM-YY'
wb = xlwt.Workbook(**kw)
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 'Test', style0)
ws.write(1, 0, datetime(2010, 12, 5), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
return wb, ws
示例6: build_result
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [as 别名]
def build_result(self, coupon_descr_list):
stk_wb = xlwt.Workbook()
myfont = xlwt.Font()
mystyle = xlwt.XFStyle()
mystyle.font = myfont
sheet_name = str(date.today())
sheet = stk_wb.add_sheet(sheet_name, cell_overwrite_ok=True)
for index, item in enumerate(coupon_descr_list):
self._write_decision_data(item, index*5, sheet)
self._write_selected_data(item, index*5, sheet)
stk_wb.save('../output/funda_rotation_{}'.format(sheet_name) + '.xls')
示例7: SankeyExport
# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import Font [as 别名]
def SankeyExport(self,Year, Path, Element): # Export data for given year in excel format for the D3.js Circular Sankey method
""" Exports MFAsystem to xls Template for the Circular Sankey method."""
TimeIndex = Year - self.Time_Start
myfont = xlwt.Font()
myfont.bold = True
mystyle = xlwt.XFStyle()
mystyle.font = myfont
Result_workbook = xlwt.Workbook(encoding = 'ascii')
Result_worksheet = Result_workbook.add_sheet('Nodes')
Result_worksheet.write(0, 0, label = 'Name', style = mystyle)
Result_worksheet.write(0, 1, label = 'Color', style = mystyle)
Result_worksheet.write(0, 2, label = 'Orientation', style = mystyle)
Result_worksheet.write(0, 3, label = 'Width', style = mystyle)
Result_worksheet.write(0, 4, label = 'Height', style = mystyle)
Result_worksheet.write(0, 5, label = 'x_position', style = mystyle)
Result_worksheet.write(0, 6, label = 'y_position', style = mystyle)
for m in range(0,len(self.ProcessList)):
if self.ProcessList[m].Graphical is None:
raise ValueError('Graphical properties of process number {foo} are not set. No export to Sankey possible, as position of process on canvas etc. needs is not specified.'.format(foo = m))
Result_worksheet.write(m +1, 0, label = self.ProcessList[m].Graphical['Name'])
Result_worksheet.write(m +1, 1, label = self.ProcessList[m].Graphical['Color'])
Result_worksheet.write(m +1, 2, label = self.ProcessList[m].Graphical['Angle'])
Result_worksheet.write(m +1, 3, label = self.ProcessList[m].Graphical['Width'])
Result_worksheet.write(m +1, 4, label = self.ProcessList[m].Graphical['Height'])
Result_worksheet.write(m +1, 5, label = self.ProcessList[m].Graphical['xPos'])
Result_worksheet.write(m +1, 6, label = self.ProcessList[m].Graphical['yPos'])
Result_worksheet = Result_workbook.add_sheet('Flows')
Result_worksheet.write(0, 0, label = 'StartNode', style = mystyle)
Result_worksheet.write(0, 1, label = 'EndNode', style = mystyle)
Result_worksheet.write(0, 2, label = 'Value', style = mystyle)
Result_worksheet.write(0, 3, label = 'Color', style = mystyle)
for key in self.FlowDict:
Result_worksheet.write(m +1, 0, label = self.FlowDict[key].P_Start)
Result_worksheet.write(m +1, 1, label = self.FlowDict[key].P_End)
Result_worksheet.write(m +1, 2, label = float(self.Flow_Sum_By_Element(key)[TimeIndex,Element]))
Result_worksheet.write(m +1, 3, label = self.FlowDict[key].Color)
Result_workbook.save(Path + self.Name + '_' + str(TimeIndex) + '_' + str(Element) + '_Sankey.xls')