kaicheng commited on
Commit
0684859
·
1 Parent(s): 79e870a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -17
app.py CHANGED
@@ -1,23 +1,30 @@
1
  import gradio as gr
2
  import pandas as pd
3
 
4
- # 定义一个函数,该函数将接受上传的XLSX文件并显示其内容
5
- def read_xlsx(file):
6
- try:
7
- # 使用pandas读取上传的XLSX文件
8
- df = pd.read_excel(file.name)
9
- # 返回XLSX文件的内容
10
- return df.to_html()
11
- except Exception as e:
12
- return str(e)
13
 
14
- # 创建Gradio界面
15
- iface = gr.Interface(
16
- fn=read_xlsx,
17
- inputs=gr.inputs.File(label="上传XLSX文件"),
18
- outputs=gr.outputs.HTML(),
19
- title="XLSX文件内容查看器"
20
- )
21
 
22
- # 启动Gradio应用程序
 
 
 
 
 
 
 
23
  iface.launch()
 
1
  import gradio as gr
2
  import pandas as pd
3
 
4
+ # # 定义一个函数,该函数将接受上传的XLSX文件并显示其内容
5
+ # def read_xlsx(file):
6
+ # try:
7
+ # # 使用pandas读取上传的XLSX文件
8
+ # df = pd.read_excel(file.name)
9
+ # # 返回XLSX文件的内容
10
+ # return df.to_html()
11
+ # except Exception as e:
12
+ # return str(e)
13
 
14
+ # # 创建Gradio界面
15
+ # iface = gr.Interface(
16
+ # fn=read_xlsx,
17
+ # inputs=gr.inputs.File(label="上传XLSX文件"),
18
+ # outputs=gr.outputs.HTML(),
19
+ # title="XLSX文件内容查看器"
20
+ # )
21
 
22
+ # # 启动Gradio应用程序
23
+ # iface.launch()
24
+
25
+ def process_excel(file):
26
+ df = pd.read_excel(file.name, engine='openpyxl')
27
+ return df
28
+
29
+ iface = gr.Interface(fn=process_excel, inputs="file", outputs="dataframe", title="Excel Processor")
30
  iface.launch()