Spaces:
Sleeping
Sleeping
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() | |