使用python读写excel文件

使用Python可以处理Excel文件。
读取数据:https://github.com/python-excel/xlrd
写数据:https://github.com/python-excel/xlwt
写数据使用示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import xlwt
from datetime import datetime

style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')

wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')

ws.write(0, 0, 1234.56, style0)
ws.write(1, 0, datetime.now(), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))

wb.save('example.xls')