1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Read Cells from Google Sheets in JavaScript or HTML

Discussion in 'Google API' started by samuvk, Sep 14, 2015.

  1. #1
    I would like to be able to read the values in a column from Google Sheet with JavaScript of HTML and add the values to a ComboBox or use them for other purpose.

    Basically I want to imitate the following action in VBA with Excel. (In excel if I want to read the Values in Column A I would do something like)

    Dim i as integer

    Dim value as string

    i = 1

    //Read value on cell A1

    Value = Range(“A” & i).value

    //Keep reading values on column A till cell is empty

    While value <> ” ”

    Value = Range(“A” & i).value

    //Add the value to ComboBox

    With ComboBox1
    .AddItem value
    End With

    //Increase value of row to look at

    i = i + 1


    Thank you so much
    samuvk, Sep 14, 2015 IP
  2. samuvk

    samuvk Greenhorn

    Likes Received:
    Best Answers:
    Trophy Points:
    Here is the code that I tried. Could anyone help me to find out what I'm doing wrong?


    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});

    // To load this function when the window loads
    window.onload = function loadStates() {

    //I select only one value (In this case Alabama, to test if it works)
    var queryStringStates = encodeURIComponent('SELECT A LIMIT 1');
    var magicIncantation = '/gviz/tq?gid=0&headers=1&tq=';

    //Put the query together
    var queryStates = new google.visualization.Query(
    'https://docs.google.com/spreadsheets/d/1xfb9trifQA5KDPc9Nh5hBL4MJ290Mxcc1Uod2VTPzYI/edit' +
    magicIncantation + queryStringStates);

    //Get the data
    var dataStates = response.getDataTable();

    //Load the data (In this case the state of Alabama) to the Selector which is in the body part with the //State of Texas by default to make sure that the Selector loads
    var x = document.getElementById("mySelect");
    var option = document.createElement("option");
    option.text = dataStates;

    <select id="mySelect">
    <option value="Texas">Texas</option>
    samuvk, Sep 15, 2015 IP
  3. redesignunit@gmail.com

    redesignunit@gmail.com Banned

    Likes Received:
    Best Answers:
    Trophy Points:
    As of now Google doesn't seems to provide JS only API for Google sheets. You need to build a JAVA or ASP.NET server to read the Google Sheets and then have your JS code call REST APIs from that server to fetch data. Check https://developers.google.com/google-apps/spreadsheets/?hl=en
    redesignunit@gmail.com, Sep 22, 2015 IP
  4. pototo

    pototo Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    I don't have a product yet. And I really need to test some stuff via the ClickBank API without having a product. Is it possible? And how?
    pototo, Feb 17, 2016 IP
  5. Sonia Akther

    Sonia Akther Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    In fact, how does the API actually work, please tell me?
    Sonia Akther, Nov 12, 2023 IP