使用xlrd读取excel并返回json

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

# -*- coding: utf-8 -*-
import sys
import xlrd
import json

file = sys.argv[1]
#print(file)
data = xlrd.open_workbook(file)
table=data.sheets()[0]
nrows=table.nrows
#print(nrows)
ncols = table.ncols
#print(ncols)
returnData={}
for i in range(nrows ):
    returnData[i]=table.row_values(i)
returnJson=json.dumps(returnData)
print(returnJson)