Spaces:
Sleeping
Sleeping
File size: 818 Bytes
9bdf4d2 |
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 |
import gradio as gr
import pandas as pd
def extract_excel(file):
# Read every sheet into a dict of DataFrames
all_sheets = pd.read_excel(file.name, sheet_name=None, engine="openpyxl")
# Build a single HTML string with each sheet
html_parts = []
for sheet_name, df in all_sheets.items():
html_parts.append(f"<h2>Sheet: {sheet_name}</h2>")
html_parts.append(df.to_html(index=False))
return "".join(html_parts)
# Set up Gradio interface
iface = gr.Interface(
fn=extract_excel,
inputs=gr.File(label="Upload an Excel file (.xlsx/.xls)"),
outputs=gr.HTML(label="Extracted Data"),
title="Excel ⇒ Data Extractor",
description="Uploads an Excel file and displays all sheets.",
allow_flagging="never"
)
if __name__ == "__main__":
iface.launch()
|