Working with Excel Files
Visualize Excel file in a table
To upload and visualize Excel spreadsheets (i.e., .xlsx
and .xlsm
files with tabular data) in Superblocks:
-
Add a FilePicker, Table, and Button component to the application UI
-
Add a backend API containing a Python step with the following code:
import pandas as pd
import json
from io import BytesIO
file_bytes = FILEPICKER_NAME.files[0].readContents("raw")
file_like_object = BytesIO(file_bytes)
df = pd.read_excel(file_like_object)
return json.loads(df.to_json(orient='records'))
- Bind the API response to the Table data and trigger the backend API from the button's onClick event handler
You can now drop an Excel file into the Filepicker and visualize the contents in your application.