赞
踩
import pandas as pd
import numpy as np
def readexcel(self):
data = pd.read_excel('xxx.xlsx')
# print(type(data))
train_data = np.array(data) # np.ndarray()
excel_list = train_data.tolist() # list
print(excel_list)
content = ''
a = '<table>'
for i in excel_list:
content+="<tr><td>"+i[0]+"</td><td>"+i[1]+"</td><td>"+i[2]+"</td></tr>"
print(content)
content = a+content+"</table>"
return content
用pandas读取excel文件,将DataFrame数据转为list,最后返回拼接好的html字符串
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。