如果我們說話pythonish,爲什麼不使用http://www.python-excel.org/?讀取文件的
例子:
import xlrd
rb = xlrd.open_workbook('file.xls',formatting_info=True)
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
row = sheet.row_values(rownum)
for c_el in row:
print c_el
寫入新文件:
import xlwt
from datetime import datetime
font0 = xlwt.Font()
font0.name = 'Times New Roman'
font0.colour_index = 2
font0.bold = True
style0 = xlwt.XFStyle()
style0.font = font0
style1 = xlwt.XFStyle()
style1.num_format_str = 'D-MMM-YY'
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 'Test', 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')
有頁面上的其他例子。
[解決方案在300萬個數據點上執行大量計算並製作圖表]的可能副本(http://support.microsoft.com/kb/3322939/solution-to-perform-lots-of-calculations-on- 3百萬個數據點和製作圖表) – 2010-07-26 20:58:53