Python's Excel file append content

Source: Internet
Author: User

The first thing to install is three modules: Xlrd,xlwt,xlutils

Command: Pip install xlrd XLWT xlutils

Example code:

1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 4  fromXlrdImportOpen_workbook5  fromXlutils.copyImportCopy6 7R_xls = Open_workbook ("Test.xls")#reading Excel Files8row = R_xls.sheets () [0].nrows#get the number of rows that are already there9Excel = Copy (R_xls)#Converts an object of Xlrd to a XLWT objectTenTable = Excel.get_sheet (0)#get the sheet to manipulate One  A #append a row to an Excel table -Table.write (row, 0,'Content 1')#the number of rows, columns, and contents in parentheses, respectively -Table.write (row, 1,'Content 2') theTable.write (Row, 2,'Content 3') -  -Excel.save ("Test.xls")#save and overwrite files

Python's Excel file append content

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.