Getting all sheets from the workbook

import streamlit as st
from streamlit_gsheets import GSheetsConnection

conn = st.connection("gsheets", type=GSheetsConnection)
df = conn.read(ttl='60m')
st.dataframe(df)

I have tried the above code to get all the worksheets from the workbook, but only getting the first one. How to get all the worksheets?

I have tried researching about the gspread package which is used by Streamlit, there is a method worksheet_list = sh.worksheets() to get all the sheet names in the workbook. But dont know how to implement it here.

1 Like

Hi @satyabansahoo2000,

Thanks for posting!

You can try iterating through each worksheet and read its data like so:

import streamlit as st
from streamlit_gsheets import GSheetsConnection

conn = st.connection("gsheets", type=GSheetsConnection)

# Get the list of all worksheets
worksheets = conn.worksheets()

for worksheet in worksheets:
    df = conn.read(sheet=worksheet.title)  # assuming 'title' is the attribute for worksheet name
    st.dataframe(df)