本文整理汇总了Python中xlwt.Font.name方法的典型用法代码示例。如果您正苦于以下问题:Python Font.name方法的具体用法?Python Font.name怎么用?Python Font.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlwt.Font
的用法示例。
在下文中一共展示了Font.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryExcel
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def queryExcel(filename, dategroup, response):
filename += u'.xls'
response['Content-Disposition'] = (u'attachment;filename=%s' % filename).encode('utf-8')
import xlwt
from xlwt import Font, Alignment
style1 = xlwt.XFStyle()
font1 = Font()
font1.height = 360
font1.name = u'仿宋'
style1.font = font1
algn = Alignment()
algn.horz = Alignment.HORZ_LEFT
style1.alignment = algn
style1.font = font1
style0 = xlwt.XFStyle()
algn0 = Alignment()
algn0.horz = Alignment.HORZ_CENTER
font = Font()
font.height = 320
font.bold = False
font.name = u'仿宋'
style0.alignment = algn0
style0.font = font
wb = xlwt.Workbook()
ws = wb.add_sheet(u"销售报表", cell_overwrite_ok=True)
rownum = 0
ws.write_merge(rownum, rownum, 0, 0, u'序号', style0)
ws.write_merge(rownum, rownum, 1, 1, u'品牌', style0)
ws.write_merge(rownum, rownum, 2, 2, u'型号', style0)
ws.write_merge(rownum, rownum, 3, 3, u'类型', style0)
ws.write_merge(rownum, rownum, 4, 4, u'数量', style0)
ws.write_merge(rownum, rownum, 5, 5, u'账户', style0)
ws.write_merge(rownum, rownum, 6, 6, u'姓名', style0)
ws.write_merge(rownum, rownum, 7, 7, u'主管', style0)
rownum += 1
datanum = 1
for data in dategroup:
ws.write_merge(rownum, rownum, 0, 7, u'日期:%s 厅台:%s 总计:%s 台' % (data['date'], data['officename'],data['totalnum']), style1)
rownum += 1
for i, row in enumerate(data['query']):
ws.write_merge(rownum, rownum, 0, 0, datanum, style0)
ws.write_merge(rownum, rownum, 1, 1, row['productbrandsname'], style0)
ws.write_merge(rownum, rownum, 2, 2, row['productname'], style0)
ws.write_merge(rownum, rownum, 3, 3, row['ordertypename'], style0)
ws.write_merge(rownum, rownum, 4, 4, row['ordernum'], style0)
ws.write_merge(rownum, rownum, 5, 5, row['username'], style0)
ws.write_merge(rownum, rownum, 6, 6, row['get_full_name'], style0)
ws.write_merge(rownum, rownum, 7, 7, row['managername'], style0)
datanum += 1
rownum += 1
for i in range(8):
ws.col(i).width = 256 * 20
wb.save(response)
示例2: queryExcel
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def queryExcel(filename, dategroup, response):
'''
导出excel
'''
filename += u'.xls'
response['Content-Disposition'] = (u'attachment;filename=%s' % filename).encode('utf-8')
import xlwt
from xlwt import Font, Alignment
style1 = xlwt.XFStyle()
font1 = Font()
font1.height = 260
font1.name = u'仿宋'
style1.font = font1
algn = Alignment()
algn.horz = Alignment.HORZ_LEFT
style1.alignment = algn
style1.font = font1
style0 = xlwt.XFStyle()
algn0 = Alignment()
algn0.horz = Alignment.HORZ_CENTER
font = Font()
font.height = 220
font.bold = False
font.name = u'仿宋'
style0.alignment = algn0
style0.font = font
wb = xlwt.Workbook()
ws = wb.add_sheet(u"考试报表", cell_overwrite_ok=True)
rownum = 0
ws.write_merge(rownum, rownum, 0, 0, u'序号', style0)
ws.write_merge(rownum, rownum, 1, 1, u'员工ID', style0)
ws.write_merge(rownum, rownum, 2, 2, u'姓名', style0)
ws.write_merge(rownum, rownum, 3, 3, u'得分', style0)
ws.write_merge(rownum, rownum, 4, 4, u'主管', style0)
rownum += 1
datanum = 1
for data in dategroup:
ws.write_merge(rownum, rownum, 0, 4, u'考试:%s 参考人数:%s 旷考人数:%s' % (data['name'],data['totalnum'],data['untotalnum']), style1)
rownum += 1
for i, row in enumerate(data['query']):
ws.write_merge(rownum, rownum, 0, 0, datanum, style0)
ws.write_merge(rownum, rownum, 1, 1, row['username'], style0)
ws.write_merge(rownum, rownum, 2, 2, row['get_full_name'], style0)
ws.write_merge(rownum, rownum, 3, 3, row['score'], style0)
ws.write_merge(rownum, rownum, 4, 4, row['managername'], style0)
datanum += 1
rownum += 1
for i in range(5):
ws.col(i).width = 256 * 10
wb.save(response)
示例3: getDefualtStyle
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def getDefualtStyle():
fnt = Font()
fnt.name = 'Arial'
borders = Borders()
borders.left = Borders.THIN
borders.right = Borders.THIN
borders.top = Borders.THIN
borders.bottom = Borders.THIN
#pattern = Pattern()
#pattern.pattern = Style.pattern_map['solid']
###pattern.pattern_back_colour = 0xBFBFBF
#pattern.pattern_fore_colour = 0x37
alignment = Alignment()
#alignment.horizontal = Alignment.HORZ_LEFT
alignment.horizontal = Alignment.HORZ_RIGHT
style = XFStyle()
#~ style.num_format_str='0.000%'
#~ style.num_format_str='0+'
#~ style.font = fnt
style.align = alignment
#style.borders = borders
#~ style.pattern = pattern
return style
示例4: defineFontStyle
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def defineFontStyle(argFontName,argIsBold):
style = XFStyle()
font = Font()
font.name = argFontName
font.bold = argIsBold
style.font = font
return style
示例5: xls_headers
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def xls_headers(self, text, title):
u"""
"""
# headers style
header1 = easyxf()
header2 = easyxf()
# font
font1 = Font()
font1.name = 'Times New Roman'
font1.bold = True
# alignment
alig1 = Alignment()
alig1.horz = 2
# assign
header1.font = font1
header1.alignment = alig1
header2.font = font1
# headers 1st sheet
self.feuy1.write_merge(0, 0, 0, 1, text.get('titre') +
title,
header1)
self.feuy1.write(1, 0, text.get('nomfic'), header2)
self.feuy1.write(2, 0, text.get('mtcthem'), header2)
self.feuy1.write(3, 0, text.get('mtcgeo'), header2)
self.feuy1.write(4, 0, text.get('description'), header2)
self.feuy1.write(5, 0, text.get('cadre'), header2)
self.feuy1.write(6, 0, text.get('num_objets'), header2)
self.feuy1.write(7, 0, text.get('num_attrib'), header2)
self.feuy1.write(8, 0, text.get('date_crea'), header2)
self.feuy1.write(9, 0, text.get('date_actu'), header2)
self.feuy1.write(10, 0, text.get('source'), header2)
self.feuy1.write(11, 0, text.get('diffusion'), header2)
self.feuy1.write(12, 0, text.get('responsable'), header2)
self.feuy1.write(13, 0, text.get('ptcontact'), header2)
self.feuy1.write(14, 0, text.get('siteweb'), header2)
self.feuy1.write(15, 0, text.get('geometrie'), header2)
self.feuy1.write(16, 0, text.get('echelle'), header2)
self.feuy1.write(17, 0, text.get('precision'), header2)
self.feuy1.write(18, 0, text.get('srs'), header2)
self.feuy1.write(19, 0, text.get('emprise'), header2)
# headers 2nd sheet
self.feuy2.write(0, 0, text.get('numero'), header2)
self.feuy2.write(0, 1, text.get('nom'), header2)
self.feuy2.write(0, 2, text.get('type'), header2)
self.feuy2.write(0, 3, text.get('longueur'), header2)
self.feuy2.write(0, 4, text.get('precision'), header2)
self.feuy2.write(0, 5, text.get('description'), header2)
self.feuy2.write(0, 6, text.get('somme'), header2)
self.feuy2.write(0, 7, text.get('moyenne'), header2)
self.feuy2.write(0, 8, text.get('mediane'), header2)
self.feuy2.write(0, 9, text.get('min'), header2)
self.feuy2.write(0, 10, text.get('max'), header2)
self.feuy2.write(0, 11, text.get('ecartype'), header2)
# End of function
return self.feuy1, self.feuy2
示例6: output
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def output(file_or_stream, sheetname, headers, values, encoding = 'utf8', footer_text = None, footer_link = None):
import xlwt
book = xlwt.Workbook(encoding)
sh = book.add_sheet(sheetname)
datestyle = XFStyle()
datestyle.num_format_str = 'DD/MM/YYYY'
timestyle = XFStyle()
timestyle.num_format_str = 'HH:MM:SS'
header_font = Font()
header_font.bold = True
al = Alignment()
al.horz = Alignment.HORZ_CENTER
header_style = XFStyle()
header_style.font = header_font
header_style.alignment = al
for i,header in enumerate(headers):
sh.write(0, i, header, header_style)
sh.set_panes_frozen(True) # frozen headings instead of split panes
sh.set_horz_split_pos(1) # in general, freeze after last heading row
sh.set_remove_splits(True) # if user does unfreeze, don't leave a split there
for j, row in enumerate(values):
for i, value in enumerate(row):
if value.__class__ == date:
sh.write(j+1, i, value, datestyle)
elif value.__class__ == time:
sh.write(j+1, i, value, timestyle)
else:
sh.write(j+1, i, value)
if footer_link and footer_text:
link_font = Font()
link_font.name = 'Verdana'
link_font.colour_index = 4
link_font.height = 20*8
al = Alignment()
al.horz = Alignment.HORZ_CENTER
al.vert = Alignment.VERT_BOTTOM
link_style = XFStyle()
link_style.font = link_font
link_style.alignment = al
row = len(values) + 1
sh.write_merge(row, row, 0, len(headers)-1, Formula('HYPERLINK("' + footer_link + '";"' + footer_text + '")'), link_style)
book.save(file_or_stream)
示例7: export
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def export(match_list, file_path):
wb = xlwt.Workbook()
ws = wb.add_sheet('Ranking')
# writing header
header = ['Ranking',
'Name',
'Rating',
'Reviews',
'Price',
'Cuisines',
'Edenred Name',
'Match',
'Edenred Address']
font = Font()
font.name = 'Arial'
font.bold = True
style = XFStyle()
style.font = font
for index in range(len(header)):
ws.write(0, index, header[index], style)
# writing restaurants
for index in range(len(match_list)):
match = match_list[index]
ws.write(index+1, 0, int(match.restaurant1.ranking))
ws.write(index+1, 1, xlwt.Formula('HYPERLINK("%s"; "%s")' % (match.restaurant1.url, match.restaurant1.name)))
ws.write(index+1, 2, float(match.restaurant1.rating.replace(',', '.')))
ws.write(index+1, 3, int(match.restaurant1.review_count))
ws.write(index+1, 4, match.restaurant1.price)
ws.write(index+1, 5, ', '.join(match.restaurant1.cuisines))
ws.write(index+1, 6, match.restaurant2.name)
ws.write(index+1, 7, int(100.0 * match.score))
address = match.restaurant2.address + ', ' + match.restaurant2.postcode
map_link = 'https://www.google.com/maps?f=q&source=s_q&hl=es&q=%s' % address
ws.write(index+1, 8, xlwt.Formula('HYPERLINK("%s"; "%s")' % (map_link, address)))
wb.save(file_path)
示例8: unicode
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
unicode(localtime()[2]) # date du jour
###################################
######### Fichier Excel ###########
###################################
# configuration du fichier excel de sortie
book = Workbook(encoding = 'utf8')
feuy1 = book.add_sheet(u'Dossiers', cell_overwrite_ok=True)
feuy2 = book.add_sheet(u'Shapes', cell_overwrite_ok=True)
feuy3 = book.add_sheet(u'Champs', cell_overwrite_ok=True)
feuy4 = book.add_sheet(u'MXD', cell_overwrite_ok=True)
feuy5 = book.add_sheet(u'Metadatos', cell_overwrite_ok=True)
# personnalisation du fichier excel
font1 = Font() # cr?ation police 1
font1.name = 'Times New Roman'
font1.bold = True
entete = XFStyle() # cr?ation style pour les en-t?tes
entete.font = font1 # application de la police 1 au style entete
hyperlien = easyxf(u'font: underline single')
erreur = easyxf(u'font: name Arial, bold 1, colour red')
# colonnes feuille dossiers
feuy1.write(0, 0, u'Nom actuel', entete)
feuy1.write(0, 1, u'Nom chang?', entete)
feuy1.write(0, 2, u'Type g?om?trie', entete)
feuy1.write(0, 3, u'Emprise', entete)
feuy1.write(0, 4, u'Projection', entete)
feuy1.write(0, 5, u'EPSG', entete)
feuy1.write(0, 6, u'Nombre de champs', entete)
示例9: report_get
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def report_get(self,cr,uid,ids,context=None):
this=self.browse(cr,uid,ids[0])
year = this.year_id.name
year_id = this.year_id.id
month = this.month
if month == '1':
month_name = 'January'
elif month == '2':
month_name = 'February'
elif month == '3':
month_name = 'March'
elif month == '4':
month_name = 'April'
elif month == '5':
month_name = 'May'
elif month == '6':
month_name = 'June'
elif month == '7':
month_name = 'July'
elif month == '8':
month_name = 'August'
elif month == '9':
month_name = 'September'
elif month == '10':
month_name = 'October'
elif month == '11':
month_name = 'November'
elif month == '12':
month_name = 'December'
else:
raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
#Define the font attributes for header
fnt = Font()
fnt.name = 'Arial'
fnt.height= 275
#Define the font attributes for header
content_fnt = Font()
content_fnt.name ='Arial'
content_fnt.height =220
align_content = Alignment()
align_content.horz= Alignment.HORZ_CENTER
borders = Borders()
borders.left = 0x02
borders.right = 0x02
borders.top = 0x02
borders.bottom = 0x02
#The text should be centrally aligned
align = Alignment()
align.horz = Alignment.HORZ_CENTER
align.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = 0x1F
#apply the above settings to the row(0) header
style_header= XFStyle()
style_header.font= fnt
style_header.pattern= pattern
style_header.borders = borders
style_header.alignment=align
#Define the font attributes for header
fnt1 = Font()
fnt1.name = 'Arial'
fnt1.height= 275
#Define the font attributes for header
content_fnt1 = Font()
content_fnt1.name ='Arial'
content_fnt1.height =220
align_content1 = Alignment()
align_content1.horz= Alignment.HORZ_CENTER
borders1 = Borders()
borders1.left = 0x02
borders1.right = 0x02
borders1.top = 0x02
borders1.bottom = 0x02
#The text should be centrally aligned
align1 = Alignment()
align1.horz = Alignment.HORZ_CENTER
align1.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
pattern1 = Pattern()
pattern1.pattern = Pattern.SOLID_PATTERN
pattern1.pattern_fore_colour = 0x32
#apply the above settings to the row(0) header
style_header1= XFStyle()
style_header1.font= fnt1
style_header1.pattern= pattern1
#.........这里部分代码省略.........
示例10: detail_budget
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def detail_budget(self,cr,uid,ids,context=None):
this=self.browse(cr,uid,ids[0])
year = this.year_id.name
year_id = this.year_id.id
month = this.month
if month == '1':
month_name = 'January'
elif month == '2':
month_name = 'February'
elif month == '3':
month_name = 'March'
elif month == '4':
month_name = 'April'
elif month == '5':
month_name = 'May'
elif month == '6':
month_name = 'June'
elif month == '7':
month_name = 'July'
elif month == '8':
month_name = 'August'
elif month == '9':
month_name = 'September'
elif month == '10':
month_name = 'October'
elif month == '11':
month_name = 'November'
elif month == '12':
month_name = 'December'
else:
raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
if int(month) in [1,3,5,7,8,10,12]:
join_date=year +'-'+month+'-'+'31'
if int(month) in [4,6,9,11]:
join_date=year +'-'+month+'-'+'30'
if int(month) in [2]:
if int(year) % 4 == 0:
join_date=year +'-'+month+'-'+'29'
else:
join_date=year +'-'+month+'-'+'28'
#Define the font attributes for header
fnt = Font()
fnt.name = 'Arial'
fnt.height= 275
#Define the font attributes for header
content_fnt = Font()
content_fnt.name ='Arial'
content_fnt.height =220
align_content = Alignment()
align_content.horz= Alignment.HORZ_CENTER
borders = Borders()
borders.left = 0x02
borders.right = 0x02
borders.top = 0x02
borders.bottom = 0x02
#The text should be centrally aligned
align = Alignment()
align.horz = Alignment.HORZ_CENTER
align.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = 0x1F
#apply the above settings to the row(0) header
style_header= XFStyle()
style_header.font= fnt
style_header.pattern= pattern
style_header.borders = borders
style_header.alignment=align
#Define the font attributes for header
fnt1 = Font()
fnt1.name = 'Arial'
fnt1.height= 275
#Define the font attributes for header
content_fnt1 = Font()
content_fnt1.name ='Arial'
content_fnt1.height =220
align_content1 = Alignment()
align_content1.horz= Alignment.HORZ_CENTER
borders1 = Borders()
borders1.left = 0x02
borders1.right = 0x02
borders1.top = 0x02
borders1.bottom = 0x02
#The text should be centrally aligned
align1 = Alignment()
align1.horz = Alignment.HORZ_CENTER
align1.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
#.........这里部分代码省略.........
示例11: account_budget
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def account_budget(self,cr,uid,ids,context=None):
this=self.browse(cr,uid,ids[0])
year = this.year_id.name
year_id = this.year_id.id
month = this.month
if int(month) in [1,3,5,7,8,10,12]:
join_date=year +'-'+month+'-'+'31'
if int(month) in [4,6,9,11]:
join_date=year +'-'+month+'-'+'30'
if int(month) in [2]:
if int(year) % 4 == 0:
join_date=year +'-'+month+'-'+'29'
else:
join_date=year +'-'+month+'-'+'28'
if month == '1':
month_name = 'January'
elif month == '2':
month_name = 'February'
elif month == '3':
month_name = 'March'
elif month == '4':
month_name = 'April'
elif month == '5':
month_name = 'May'
elif month == '6':
month_name = 'June'
elif month == '7':
month_name = 'July'
elif month == '8':
month_name = 'August'
elif month == '9':
month_name = 'September'
elif month == '10':
month_name = 'October'
elif month == '11':
month_name = 'November'
elif month == '12':
month_name = 'December'
else:
raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
#Define the font attributes for header
fnt = Font()
fnt.name = 'Arial'
fnt.height= 275
#Define the font attributes for header
content_fnt = Font()
content_fnt.name ='Arial'
content_fnt.height =220
align_content = Alignment()
align_content.horz= Alignment.HORZ_CENTER
borders = Borders()
borders.left = 0x02
borders.right = 0x02
borders.top = 0x02
borders.bottom = 0x02
#The text should be centrally aligned
align = Alignment()
align.horz = Alignment.HORZ_CENTER
align.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = 0x1F
#apply the above settings to the row(0) header
style_header= XFStyle()
style_header.font= fnt
style_header.pattern= pattern
style_header.borders = borders
style_header.alignment=align
#Define the font attributes for header
fnt1 = Font()
fnt1.name = 'Arial'
fnt1.height= 275
#Define the font attributes for header
content_fnt1 = Font()
content_fnt1.name ='Arial'
content_fnt1.height =220
align_content1 = Alignment()
align_content1.horz= Alignment.HORZ_CENTER
borders1 = Borders()
borders1.left = 0x02
borders1.right = 0x02
borders1.top = 0x02
borders1.bottom = 0x02
#The text should be centrally aligned
align1 = Alignment()
align1.horz = Alignment.HORZ_CENTER
align1.vert = Alignment.VERT_CENTER
#We set the backgroundcolour here
#.........这里部分代码省略.........
示例12: write_sheet
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def write_sheet(self, data, sheet_name, print_to_screen=False):
'''Write a very simple table to a new sheet in a spreadsheet,
Optionally, print the table to the screen'''
# most cells
al = Alignment()
al.horz = Alignment.HORZ_RIGHT
al.vert = Alignment.VERT_CENTER
font = Font()
font.name = 'Arial'
font.height = 9 * 20 # 9 pt
style = XFStyle()
style.font = font
style.alignment = al
# tops cells
al = Alignment()
al.horz = Alignment.HORZ_CENTER
al.vert = Alignment.VERT_CENTER
font = Font()
font.name = 'Arial'
font.bold = True
font.height = 9 * 20 # 9 pt
style_top = XFStyle()
style_top.font = font
style_top.alignment = al
# left cells
al = Alignment()
al.horz = Alignment.HORZ_LEFT
al.vert = Alignment.VERT_CENTER
font = Font()
font.name = 'Arial'
font.bold = True
font.italic = True
font.height = 9 * 20 # 9 pt
style_left = XFStyle()
style_left.font = font
style_left.alignment = al
ws = self.add_sheet(sheet_name)
for i, row in enumerate(data):
for j, cell in enumerate(row):
borders = Borders()
if i == 0:
borders.top = 1
borders.bottom = 2
if i == len(row) - 1:
borders.bottom = 1
if j == 0:
borders.left = 1
borders.right = 1
if j == len(row) - 1:
borders.right = 1
if j == 0:
_style = style_left
elif i == 0:
_style = style_top
else:
_style = style
_style.borders = borders
# one of the libraries can get confused with plain strings
if isinstance(cell, str):
cell = unicode(cell, 'utf-8')
ws.write(i + 1, j + 1, cell, _style)
if print_to_screen:
print print_table(data, sheet_name, bold=True)
示例13: Font
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
from datetime import date
from xlwt import Workbook, XFStyle, Borders, Pattern, Font
fnt = Font()
fnt.name = "Arial"
borders = Borders()
borders.left = Borders.THICK
borders.right = Borders.THICK
borders.top = Borders.THICK
borders.bottom = Borders.THICK
pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = 0x0A
style = XFStyle()
style.num_format_str = "YYYY-MM-DD"
style.font = fnt
style.borders = borders
style.pattern = pattern
book = Workbook()
sheet = book.add_sheet("A Date")
sheet.write(1, 1, date(2009, 3, 18), style)
sheet.row(1).height = 256 * 20
book.save("date.xls")
示例14: Alignment
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
alignCenter = Alignment()
alignCenter.horz = Alignment.HORZ_CENTER
alignCenter.vert = Alignment.VERT_CENTER
# Top alignment, should be used for all cells
topAlign = Alignment()
topAlign.vert = Alignment.VERT_TOP
# header centered and wrapped
alignWrap = Alignment()
alignWrap.horz = Alignment.HORZ_CENTER
alignWrap.wrap = Alignment.WRAP_AT_RIGHT
# normal font
normFont = Font()
normFont.name = 'Arial'
# headers font
fntHeaders = Font()
fntHeaders.height = 200
fntHeaders.name = 'Arial'
# header styles
styleHeaders = XFStyle()
styleHeaders.font = fntHeaders
styleHeaders.alignment.wrap = True
styleHeaders.alignment = alignCenter
# headers with boarder
styleHeadersWithBorder = XFStyle()
styleHeadersWithBorder.font = fntHeaders
示例15: archivo_excel
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import name [as 别名]
def archivo_excel(titulo, archivo_logo = 'unprg.bmp', label_resumen = [], datos_resumen = [], heads = [], color = 0x9ACD32, registros = [], nombre_archivo = 'descargar.xls'):
book = Workbook()
sheet1 = book.add_sheet('Hoja 01')
#estilos de celda titulo
fnt_titulo = Font()
fnt_titulo.name = 'Arial'
fnt_titulo.bold = True
style_titulo = XFStyle()
style_titulo.font = fnt_titulo
#estilos de celda etiqueta resumen
fnt_etiqueta_resumen = Font()
fnt_etiqueta_resumen.name = 'Arial'
fnt_etiqueta_resumen.bold = True
style_etiqueta_resumen = XFStyle()
style_etiqueta_resumen.font = fnt_etiqueta_resumen
#estilos de celda datos resumen
fnt_dato_resumen = Font()
fnt_dato_resumen.name = 'Arial'
style_dato_resumen = XFStyle()
style_dato_resumen.font = fnt_dato_resumen
#estilos de celda heads
fnt_heads = Font()
fnt_heads.name = 'Arial'
fnt_heads.bold = True
borders_heads = Borders()
borders_heads.left = Borders.THIN
borders_heads.right = Borders.THIN
borders_heads.top = Borders.THIN
borders_heads.bottom = Borders.THIN
pattern_heads = Pattern()
pattern_heads.pattern = Pattern.SOLID_PATTERN
pattern_heads.pattern_fore_colour = color
style_heads = XFStyle()
style_heads.font = fnt_heads
style_heads.borders = borders_heads
style_heads.pattern = pattern_heads
#estilos de celda registros
fnt_registros = Font()
fnt_registros.name = 'Arial'
borders_registros = Borders()
borders_registros.left = Borders.THIN
borders_registros.right = Borders.THIN
borders_registros.top = Borders.THIN
borders_registros.bottom = Borders.THIN
style_registros = XFStyle()
style_registros.font = fnt_registros
style_registros.borders = borders_registros
sheet1.insert_bitmap(settings.MEDIA_ROOT + 'archivos_excel/%s' % archivo_logo, 1, 0)
#escribir el titulo
sheet1.write(10,0,titulo, style_titulo)
row = 12
col = 0
#escribir las etiquetas del resumen
for etiqueta in label_resumen:
sheet1.write(row, col, etiqueta, style_etiqueta_resumen)
row+=1
row = 12
col = 1
#escribir los datos del resumen
for dato in datos_resumen:
sheet1.write(row, col, dato, style_dato_resumen)
row+=1
row+=1
col = 0
#escribimos los encabezados
for head in heads:
sheet1.write(row,col,head,style_heads)
col+=1
row+=1
col=1
n = 1
#recorremos la lista y escribimos los datos
for fila in registros:
sheet1.write(row,0,n,style_registros)
for dato in fila:
sheet1.write(row,col,dato,style_registros)
col+=1
col=1
row+=1
n+=1
#.........这里部分代码省略.........