python xlrd xlwt擷取資料到execl表格範例

來源:互聯網
上載者:User

標籤:ESS   user   exce   sheet   mock   res   start   表格   enc   

import mock

#coding:gbk
from xlrd import open_workbook
import mock
import xlrd
import xlwt
from xlutils.copy import copy
import os
acct = mock.acct_id
data = mock.acct_data
start_time = mock.start_time
print start_time
end_time = mock.end_time5
haoshi = mock.result_end
req_sn = mock.mock(acct).format(acct, data)[‘request_sn‘]
ww = ["acct",‘wwwwww‘]
print
if os.path.exists(‘C:\Users\Administrator\desktop\excel.xls‘):
pass
else:
book = xlwt.Workbook(encoding=‘gbk‘,style_compression=0)
sheet = book.add_sheet(‘資料統計‘,cell_overwrite_ok=True)
book.save(‘C:\Users\Administrator\desktop\excel.xls‘)
book = open_workbook(‘C:\Users\Administrator\desktop\excel.xls‘,‘w+b‘)
rows = book.sheets()[0].nrows
excel = copy(book)
table = excel.get_sheet(0)
row = rows
for i in range(7):
table.col(i).width=256*35
row0 = [u‘response_sn‘,u‘retcode‘,u‘acct_id‘,u‘請求時間‘,u‘結束時間‘,u‘耗時‘]
row1 = [req_sn, mock.retcode, acct, start_time, end_time, haoshi]
if row == 0:
for i in range(len(row0)):
table.write(row, i, row0[i])
table.write(row + 1 , i, row1[i])
else:
for i in range(0,len(row0)):
table.write(row,i,row1[i])
excel.save(‘C:\Users\Administrator\desktop\excel.xls‘)

python xlrd xlwt擷取資料到execl表格範例

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.