Spaces:
Sleeping
Sleeping
File size: 884 Bytes
0684859 abf13b5 0684859 79e870a 0684859 45e5368 0684859 68bed64 bc16910 45e5368 67af0f4 45e5368 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# # 定义一个函数,该函数将接受上传的XLSX文件并显示其内容
# def read_xlsx(file):
# try:
# # 使用pandas读取上传的XLSX文件
# df = pd.read_excel(file.name)
# # 返回XLSX文件的内容
# return df.to_html()
# except Exception as e:
# return str(e)
# # 创建Gradio界面
# iface = gr.Interface(
# fn=read_xlsx,
# inputs=gr.inputs.File(label="上传XLSX文件"),
# outputs=gr.outputs.HTML(),
# title="XLSX文件内容查看器"
# )
# # 启动Gradio应用程序
# iface.launch()
import gradio as gr
import pandas as pd
def process_excel(file):
df = pd.read_excel(file.name, engine='openpyxl')
df = pd.DataFrame(df)
return df
iface = gr.Interface(fn=process_excel, inputs="file", outputs=[gr.outputs.Dataframe(type='pandas')], title="Excel Processor")
iface.launch(debug=True) |