Spaces:
Sleeping
Sleeping
# # 定义一个函数,该函数将接受上传的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) |