关于xlsxwirter,本质是xls的python模块,考虑到xls在我们的日常生活中如此重要,还是有必要掌握的。
工欲善其事必先利其器
install:
pip install XlsxWriter
example :
#coding:utf-8
import xlsxwriter;
wrkbk=xlsxwriter.Workbook("demo.xlsx");
wrksht=wrkbk.add_worksheet("mysheet");
wrksht.write('a1','value of a1')
wrksht.write('a2','add by kinfinger')
wrkbk.close()
test:
C:\Users\kinfinger\Desktop>python xx.py
Traceback (most recent call last):
File "xx.py", line 6, in
wrksht.write('a1','value of a1')
File "C:\Python27\lib\site-packages\xlsxwriter\worksheet.py", line 60, in cell
_wrapper
new_args = list(xl_cell_to_rowcol(args[0]))
File "C:\Python27\lib\site-packages\xlsxwriter\utility.py", line 108, in xl_ce
ll_to_rowcol
col_str = match.group(2)
AttributeError: 'NoneType' object has no attribute 'group'
Exception Exception: Exception('Exception caught in workbook destructor. Explici
t close() may be required for workbook.',) in > ignored
发现原来是由于XLSXWIRTE区分大小写的原因,修改为大写,程序正常
wrksht.write('A1','value of a1')
效果如下:
![运行效果](H:/python/a.jpg “ 目前不是免费,感兴趣的筒子手工测试看一下吧”)
阅读(2843) | 评论(0) | 转发(0) |