Python xlrd xlwt get data to execl table sample

Source: Internet
Author: User

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 (' Data statistics ', 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 ' request time ', U ' End time ', U ' duration ']
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 get data to execl table sample

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.