用openpyxl读取excel文件(已封装)

yangyang0826 0

import openpyxl

def readExcel(path_name):
myxl = openpyxl.load_workbook(path_name)#加载一个excel文件
myexcel = myxl.active#获取活跃的excel
col = myexcel.max_column#获取最大列数
#print(col)
row = myexcel.max_row#获取最大行数
#print(row)
for i in range(1,row+1):
print(”)
for j in range (1,col+1):
mycell = myexcel.cell(i,j)#获取表格小空间
print(str(mycell.value)+’ ‘,end=”)


发表回复