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