Python module OPENPYXL read Excel file

Source: Internet
Author: User

Use the OPENPYXL module to read Excel.

Let's look at what Excel is before the operation. Right now, only the XLSX-formatted Excel read is supported.

What do I do now to insert 3,3,3 on the third line?

#!/usr/bin/env python# _*_ coding:utf-8 _*_# import Excel read module from OPENPYXL import load_workbookfrom Openpyxl.cell import Get_c olumn_letter# loading an Excel file into a Memory object WB = Load_workbook (filename=u ' C:\kong_t1.xlsx ') # Get all sheet pages # sheetnames = wb.get_sheet_ Names () Sheetnames = wb.sheetnames# Gets the data within the first sheet page ws = Wb.get_sheet_by_name (Sheetnames[0])
#获取sheet中最大行数与最大列数rows = Ws.max_rowcols = ws.max_columnfor i in range (1,rows+1): for L in range (1,cols+1): col = g Et_column_letter (l) print Ws.cell ('%s%s '% (col,i)). value# Append one row of data at the end of the file Ws.append ([3,3,3]) wb.save (' kong.xlsx ')

Eventually

Python module OPENPYXL read Excel file

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.