-
python调用xlrd&xlsxwirter
- import xlsxwriter,xlrd
- import sys,os.path
- fname = 'zm6.xlsx'
- if not os.path.isfile(fname):
- print u'文件路径不存在'
- sys.exit()
- data = xlrd.open_workbook(fname)
- data.sheet_names()
- table = data.sheet_by_index(0)
- nrows = table.nrows
- ncols = table.ncols
- workbook = xlsxwriter.Workbook('zm6.xlsx')
- worksheet = workbook.add_worksheet()
- worksheet.set_column(0,ncols,22)
- top = workbook.add_format({'border':1,'align':'center','bg_color':'cccccc','font_size':13,'bold':True})
- green = workbook.add_format({'border':1,'align':'center','bg_color':'green','font_size':12})
- yellow = workbook.add_format({'border':1,'bg_color':'yellow','font_size':12})
- red = workbook.add_format({'border':1,'align':'center','bg_color':'red','font_size':12})
- blank = workbook.add_format({'border':1})
- for i in xrange(nrows):
- worksheet.set_row(i,22)
- for j in xrange(ncols):
- cell_value = table.cell_value(i,j,)
- if i == 0:
- format = top
- elif i == 3 or i == 6:
- format = blank
- else:
- if j == 0 or j == 2:
- format = yellow
- elif j == 1:
- format = red
- elif j == 3:
- format = green
- green.set_num_format('yyyy-mm-dd')
- worksheet.write(i,j,cell_value,format)
- format.set_align('vcenter')
- workbook.close()
-
相关阅读:
myaql常用函数
mysql常用表/视图管理语句
mysql中select五种子句和统计函数
mysql里表以及列的增删改查
mysql列类型
如何删除openfire for苹果,彻底卸载!
XMPP 服务器 Openfire 的 Emoji 支持问题(进行部分修改)
iOS5.1下emoji表情显示方框的解决办法
iOS 获取字符串中的单个字符
iOS XMPP之常见错误一:(<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>)
-
原文地址:https://www.cnblogs.com/jerryhua/p/6064908.html
Copyright © 2020-2023
润新知