Jump to content

Display data from a specific cell in google sheet on a page.

Recommended Posts

  • Replies 2
  • Views 2.4k
  • Created
  • Last Reply

What you want is doable. Although a bit involved. In general and in its simplest form you need a Google sheet that is public. The Google sheet id and a Google API Key set up to access the Google Sheets API.

Then in a code block you'd do something like the following. I'm using Javascript/jQuery here.

<div id="specific-cell-from-google-sheet">

  </div>
  
<script>

  ( ( ) => {
  
    const googleApiKey = '[enter google api key]';
    
    const googleSheetId = '[enter google sheet id]';
    
    const googleSheetName = 'Sheet1';
    
    const googleSheetRange = 'A1';
    
    const googleSheetsApiUrl = 'https://sheets.googleapis.com/v4/spreadsheets';
    
    const url = googleSheetsApiUrl +
    
      '/' +
      
      googleSheetId +
      
      '/values/' +
      
      googleSheetName +
      
      '!' +
      
      googleSheetRange;
      
    $.getJSON ( url, { key : googleApiKey }, function ( data ) {
    
      $( '#specific-cell-from-google-sheet' ).text ( data.values [ 0 ] );
      
      } );
      
    } ) ( );
    
  </script>

These are not instructions about how to do something specific but a guide on one way a particular goal might be reached.

There is voluminous information on the web about the elements involved.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

You can publish the spreadsheet in html format and use ajax to fetch for its data, using a javascript snippet

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.