Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
# 定义一个函数,该函数将接受上传的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() |