本文整理汇总了Python中xlwt.Font.height方法的典型用法代码示例。如果您正苦于以下问题:Python Font.height方法的具体用法?Python Font.height怎么用?Python Font.height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlwt.Font
的用法示例。
在下文中一共展示了Font.height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryExcel
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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 height [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: get_styles
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def get_styles():
style = easyxf(
'font: name Arial;'
)
style_s = easyxf(
'font: name Arial;'
'borders: left thin, right thin, top medium, bottom thin;'
)
style_m = easyxf(
'font: name Arial, bold True;'
'borders: left thin, right thin, top thin, bottom thin;'
)
font = Font()
font.bold = 1
font.height = 320
style.font = font
style.alignment.horz = Alignment.HORZ_LEFT
style.alignment.vert = Alignment.VERT_CENTER
style_s.font.height = 200
style_s.font.bold = 1
style_s.alignment.horz = Alignment.HORZ_CENTER
style_s.alignment.vert = Alignment.VERT_CENTER
style_s.alignment.wrap = True
return style, style_s, style_m
示例4: output
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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)
示例5: __init__
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def __init__(self):
self.style = XFStyle()
base_font = Font() # 设置基本字体
base_font.height = FONT_SIZE_UNIT * 12
self.style.font = base_font
alignment = Alignment() # 设置对齐
alignment.horz = Alignment.HORZ_CENTER
alignment.vert = Alignment.VERT_CENTER
self.style.alignment = alignment
borders = Borders() # 设置边框
borders.left = Borders.THIN
borders.right = Borders.THIN
borders.top = Borders.THIN
borders.bottom = Borders.THIN
borders.left_colour = COLOUR_BLACK
borders.right_colour = COLOUR_BLACK
borders.top_colour = COLOUR_BLACK
borders.bottom_colour = COLOUR_BLACK
self.style.borders = borders
self.style.num_format_str = '#,##0' # 设置数字格式
示例6: report_get
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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
#.........这里部分代码省略.........
示例7: detail_budget
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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
#.........这里部分代码省略.........
示例8: account_budget
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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
#.........这里部分代码省略.........
示例9: produce_summary
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def produce_summary(self, cr, uid, travel, context=None):
number_format = _('#,##0.00 [$$-C0C];-#,##0.00 [$$-C0C]')
total_fnt = Font()
total_fnt.name = 'Calibri'
total_fnt.bold = True
total_fnt.height = 16 * 20 # font size 12
total_cell_l_style = XFStyle()
total_cell_l_style.alignment = Column.title_aln
total_cell_l_style.borders = Borders()
total_cell_l_style.borders.left = Borders.THICK
total_cell_l_style.borders.right = Borders.HAIR
total_cell_l_style.borders.top = Borders.THICK
total_cell_l_style.borders.bottom = Borders.THICK
total_cell_l_style.pattern = Column.title_ptn
total_cell_l_style.num_format_str = number_format
total_cell_l_style.font = Column.obj_fnt
total_cell_r_style = XFStyle()
total_cell_r_style.alignment = Column.title_aln
total_cell_r_style.borders = Borders()
total_cell_r_style.borders.left = Borders.HAIR
total_cell_r_style.borders.right = Borders.THICK
total_cell_r_style.borders.top = Borders.THICK
total_cell_r_style.borders.bottom = Borders.THICK
total_cell_r_style.pattern = Column.title_ptn
total_cell_r_style.num_format_str = number_format
total_cell_r_style.font = Column.obj_fnt
sub_total_cell_label = Cell(
_(u'SOUS-TOTAL'), Column.title_fnt, Column.title_aln,
total_cell_l_style.borders, Column.title_ptn)
total_cell_label = Cell(
_(u'TOTAL'), total_fnt, Column.title_aln,
total_cell_r_style.borders, Column.title_ptn, number_format)
journeys = [j for i in travel.passenger_ids for j in i.journey_ids]
w = Workbook()
ws = w.add_sheet(_('Travel Summary'))
ws.row(2).height = 0x0280
ws.row(3 + len(journeys)).height = 0x0140
ws.row(4 + len(journeys)).height = 0x0180
row = 0
row += 2
_excel_columns = self.get_excel_columns(context)
# Write headers
for i, col in enumerate(_excel_columns):
ws.col(i).width = col.width
ws.write(row, i, col.text, col.style)
row += 1
for i, obj in enumerate(journeys):
ws.write(row + i, 0, i + 1, _excel_columns[0].obj_style)
for j in xrange(1, len(_excel_columns)):
ws.write(row + i, j,
_excel_columns[j].func(obj),
_excel_columns[j].obj_style)
row += len(journeys)
rate_index = [i for i, x in enumerate(_excel_columns)
if x.text == _('TICKET RATE')][0] - 1
cost_index = [i for i, x in enumerate(_excel_columns)
if x.text == _('COSTS')][0] - 1
total_index = [i for i, x in enumerate(_excel_columns)
if x.text == _('TOTAL')][0] - 1
# Sub total label
ws.write_merge(row, row, 0, rate_index,
sub_total_cell_label.text,
sub_total_cell_label.style)
# Sub totals
ws.write(row, rate_index + 1,
Formula("SUM(%s%d:%s%d)" % (chr(66 + rate_index), 4,
chr(66 + rate_index), row)),
total_cell_l_style)
ws.write(row, rate_index + 2,
Formula("SUM(%s%d:%s%d)" % (chr(66 + cost_index), 4,
chr(66 + cost_index), row)),
total_cell_r_style)
total_top_underline_style = XFStyle()
total_top_underline_style.borders = Borders()
total_top_underline_style.borders.top = Borders.THICK
total_top_underline_style.font = Column.obj_fnt
# Draw a line above total to close box
ws.write(row, total_index + 1, "", total_top_underline_style)
row += 1
# Total label
ws.write_merge(row, row, 0, rate_index,
total_cell_label.text,
total_cell_label.style)
# Total
ws.write_merge(row, row, rate_index + 1, total_index,
Formula("%s%d+%s%d" % (chr(66 + rate_index), row,
chr(66 + cost_index), row)),
total_cell_label.style)
return w
示例10: qiandaoXls
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def qiandaoXls(filename,qiandao,dategroup,mi,response):
import uuid
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=320
font1.name=u'仿宋'
style1.font=font1
algn=Alignment()
algn.horz=Alignment.HORZ_RIGHT
style1.alignment=algn
style0=xlwt.XFStyle()
algn0=Alignment()
algn0.horz=Alignment.HORZ_CENTER
algn0.vert=Alignment.VERT_CENTER
font=Font()
font.height=320
font.bold=False
font.name=u'仿宋'
style0.alignment=algn0
style0.font=font
style3=xlwt.XFStyle()
algn3=Alignment()
algn3.horz=Alignment.HORZ_CENTER
font3=Font()
font3.height=320
font3.bold=False
font1.name=u'仿宋'
style3.alignment=algn3
style3.font=font3
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour =2
style3.pattern=pattern
wb=xlwt.Workbook()
style2=xlwt.XFStyle()
algn2=Alignment()
algn2.horz=Alignment.HORZ_LEFT
font2=Font()
font2.height=350
font2.bold=True
font1.name=u'仿宋'
style2.alignment=algn2
style2.font=font2
wb=xlwt.Workbook()
ws=wb.add_sheet(u"签到报表",cell_overwrite_ok=True)
rownum=2
usernum=1
ws.write_merge(0,1,0,0,u'序号',style2)
ws.write_merge(0,1,1,1,u'员工ID',style2)
ws.col(1).width=0x0d00 +3000
ws.write_merge(0,1,2,2,u'姓名',style2)
ws.col(2).width=0x0d00 +3000
for i,q in enumerate(qiandao):
ws.write_merge(0,0,5*i+3,5*i+6,q.name,style2)
ws.write_merge(1,1,5*i+3,5*i+3,u'厅台',style2)
ws.col(5*i+3).width=0x0d00 + 7000
ws.write_merge(1,1,5*i+4,5*i+4,u'地址',style2)
ws.col(5*i+4).width=0x0d00 + 9000
ws.write_merge(1,1,5*i+5,5*i+5,u'时间',style2)
ws.write_merge(1,1,5*i+6,5*i+6,u'位置判断',style2)
ws.col(6).width=0x0d00 +3000
ws.write_merge(1,1,5*i+7,5*i+7,u'时间判读',style2)
ws.col(7).width=0x0d00 +3000
for data in dategroup:
ws.write_merge(rownum,rownum,0,data['rowspan2'],u'日期:%s'%(data['date'],),style2)
rownum+=1
tempnum=0
for query in data['query']:
for i,rows in enumerate(query['qiandaolist']):
for j,row in enumerate(rows):
ws.write_merge(rownum+j,rownum+j,3+i*5+0,3+i*5+0,row['officename'],style0)
ws.write_merge(rownum+j,rownum+j,3+i*5+1,3+i*5+1,row['address'],style0)
ws.write_merge(rownum+j,rownum+j,3+i*5+2,3+i*5+2,row['dateTime'],style0)
if row['officegps']:
if row['gpsdistance']<mi:
ws.write_merge(rownum+j,rownum+j,3+i*5+3,3+i*5+3,u'合格',style0)
else:
ws.write_merge(rownum+j,rownum+j,3+i*5+3,3+i*5+3,u'不合格',style3)
else:
ws.write_merge(rownum+j,rownum+j,3+i*5+3,3+i*5+3,u'0',style0)
if row['time']:
ws.write_merge(rownum+j,rownum+j,3+i*5+4,3+i*5+4,u'合格',style0)
else:
ws.write_merge(rownum+j,rownum+j,3+i*5+4,3+i*5+4,u'不合格',style3)
if tempnum<j:
tempnum=j
ws.write_merge(rownum,rownum+tempnum,0,0,usernum,style0)
ws.write_merge(rownum,rownum+tempnum,1,1,query['user']['username'],style0)
ws.write_merge(rownum,rownum+tempnum,2,2,query['user']['get_full_name'],style0)
rownum+=tempnum+1
usernum+=1
wb.save(response)
示例11: CreateExcelSpreadsheet
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def CreateExcelSpreadsheet(table, output_excel, use_alias=True):
"""Exports table to excel
Required:
table -- input table
output_excel -- output excel table (.xlsx, .xls)
Optional:
use_alias -- use field alias name for column headers. Default is True
"""
# build field dict
fieldNames = [(f.name, f.aliasName) for f in arcpy.ListFields(table) if f.type != 'Geometry']
fields = [f[1] if use_alias in ('true', True) else f[0] for f in fieldNames]
widths = {i: arial10.fitwidth(f) + 1024 for i,f in enumerate(fields)}
# get field values *Changed from type dict to list
with arcpy.da.SearchCursor(table, [f[0] for f in fieldNames]) as rows:
values = [r for r in rows]
# Create spreadsheet
wb = Workbook()
ws = wb.add_sheet('Sheet 1')
cols = len(fields)
rows = len(values) + 1
# set styles
#***************************************************************************
borders = Borders()
borders.left = Borders.THIN
borders.right = Borders.THIN
borders.top = Borders.THIN
borders.bottom = Borders.THIN
style = XFStyle()
style.borders = borders
# headers
fntHeaders = Font()
fntHeaders.bold = True
fntHeaders.height = 220
styleHeaders = XFStyle()
styleHeaders.font = fntHeaders
styleHeaders.borders = borders
# for date fields
styleDate = XFStyle()
styleDate.borders = borders
styleDate.num_format_str = 'MM/DD/YYYY'
#***************************************************************************
# write headers and freeze panes
for ci,field in enumerate(fields):
ws.write(0, ci, field, styleHeaders)
# freeze headers
ws.set_panes_frozen(True)
ws.set_horz_split_pos(1)
# fill in values
start = 1
for vals in values:
for i, value in enumerate(vals):
ws.write(start, i, value, styleDate if isinstance(value, datetime.datetime) else style)
v_width = arial10.fitwidth(str(value).strip())
if v_width > widths[i]:
widths[i] = v_width
start += 1
if not start % 1000:
ws.flush_row_data()
# autofit column widths
for ci,width in widths.iteritems():
ws.col(ci).width = int(width + 256) # just a little more padding
# save workbook
wb.save(output_excel)
del wb
out_url = '/'.join([PATH_URL, os.path.basename(out_file)])
arcpy.SetParameter(2, out_url)
arcpy.AddMessage(out_url)
return out_url
示例12: output
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
def output(self):
# from xlrd import open_workbook
from xlwt import Workbook, XFStyle, Borders, Alignment, Font, Pattern, Style, easyxf
# from xlutils.copy import copy
"""
rb = open_workbook(r"Templates\template.xls")
wb = copy(rb)
s = wb.get_sheet(0)
s.write(0, 0, 'A1')
wb.save(r"C:\Temp\nephro-planner\new.xls")
"""
book = Workbook(encoding="utf-8")
sheet = book.add_sheet(r"Feuille1")
style_title = XFStyle()
font_title = Font()
font_title.name = "Comic Sans MS"
font_title.height = 280
style_title.font = font_title
style_title.alignment.horz = Alignment.HORZ_CENTER
style_title.alignment.vert = Alignment.VERT_CENTER
style_cell_bottom = XFStyle()
borders_cell_bottom = Borders()
borders_cell_bottom.bottom = Borders.MEDIUM
style_cell_bottom.borders = borders_cell_bottom
style_header = XFStyle()
font_header = Font()
font_header.bold = 1
font_header.name = "Arial Narrow"
font_header.height = 240
style_header.font = font_header
style_header.alignment.horz = Alignment.HORZ_CENTER
style_header.alignment.vert = Alignment.VERT_CENTER
borders_header = Borders()
borders_header.top = Borders.MEDIUM
borders_header.left = Borders.MEDIUM
borders_header.bottom = Borders.MEDIUM
borders_header.right = Borders.MEDIUM
style_header.borders = borders_header
style_sub_header = XFStyle()
font_sub_header = Font()
font_sub_header.name = "Arial Narrow"
font_sub_header.height = 240
style_sub_header.font = font_sub_header
style_sub_header.alignment.horz = Alignment.HORZ_CENTER
style_sub_header.alignment.vert = Alignment.VERT_CENTER
borders_sub_header = Borders()
borders_sub_header.top = Borders.MEDIUM
borders_sub_header.left = Borders.MEDIUM
borders_sub_header.bottom = Borders.MEDIUM
borders_sub_header.right = Borders.MEDIUM
style_sub_header.borders = borders_sub_header
style_date = XFStyle()
font_date = Font()
font_date.name = "Arial Narrow"
font_date.height = 240
style_date.font = font_date
style_date.alignment.horz = Alignment.HORZ_RIGHT
style_date.alignment.vert = Alignment.VERT_CENTER
borders_date = Borders()
borders_date.left = Borders.MEDIUM
style_date.borders = borders_date
style_date_status = XFStyle()
font_date_status = Font()
font_date_status.name = "Arial Narrow"
font_date_status.height = 240
style_date_status.font = font_date_status
style_date_status.alignment.horz = Alignment.HORZ_LEFT
style_date_status.alignment.vert = Alignment.VERT_CENTER
borders_date_status = Borders()
borders_date_status.right = Borders.MEDIUM
style_date_status.borders = borders_date_status
style_cell_normal = XFStyle()
font_cell_normal = Font()
font_cell_normal.name = "Arial Narrow"
font_cell_normal.height = 220
style_cell_normal.font = font_cell_normal
style_cell_normal.alignment.horz = Alignment.HORZ_CENTER
style_cell_normal.alignment.vert = Alignment.VERT_CENTER
style_cell_right = XFStyle()
font_cell_right = Font()
font_cell_right.name = "Arial Narrow"
font_cell_right.height = 220
style_cell_right.font = font_cell_right
style_cell_right.alignment.horz = Alignment.HORZ_CENTER
style_cell_right.alignment.vert = Alignment.VERT_CENTER
borders_cell_right = Borders()
borders_cell_right.right = Borders.MEDIUM
style_cell_right.borders = borders_cell_right
#.........这里部分代码省略.........
示例13: write_sheet
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [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)
示例14: hasattr
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
title_bold = settings.EXPORT_EXCEL_TITLE_BOLD
if hasattr(settings, 'EXPORT_EXCEL_HEADER_BOLD'):
header_bold = settings.EXPORT_EXCEL_HEADER_BOLD
if hasattr(settings, 'EXPORT_EXCEL_CELL_BOLD'):
cell_bold = settings.EXPORT_EXCEL_CELL_BOLD
titleFont.bold = title_bold # Setting title font to bold
headerFont.bold = header_bold # Setting column header font to bold
cellFont.bold = cell_bold # Setting cell font to bold
titlesize = 240 # 12*20 = 240 Font Size
fontsize = 200# 10*20 = 200 Font Size
if hasattr(settings, 'EXPORT_EXCEL_TITLE_SIZE'):
titlesize = settings.EXPORT_EXCEL_TITLE_SIZE
if hasattr(settings, 'EXPORT_EXCEL_FONT_SIZE'):
fontsize = settings.EXPORT_EXCEL_FONT_SIZE
titleFont.height = titlesize
headerFont.height = fontsize
cellFont.height = fontsize
brdLeft = Borders() # Defining border which is around header
brdLeft.left = 0x01
brdRight = Borders() # Defining border which is around header
brdRight.right = 0x01
brdTop = Borders() # Defining border which is around header
brdTop.top = 0x01
brdBottom = Borders() # Defining border which is around header
brdBottom.bottom = 0x01
示例15: Alignment
# 需要导入模块: from xlwt import Font [as 别名]
# 或者: from xlwt.Font import height [as 别名]
# 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
styleHeadersWithBorder.alignment.wrap = True
styleHeadersWithBorder.alignment = alignWrap
styleHeadersWithBorder.borders = yearBorders