Skip to main content

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:

  1. Add a FilePicker, Table, and Button component to the application UI

  2. 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'))
  1. 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.

Upload an Excel file to display in a table