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 <> ” ”
    SEMrush
    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

    Do



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

    samuvk Greenhorn

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

    Thanks


    <html>
    <head>
    <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;
    x.add(option);
    }
    </script>
    </head>

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

    redesignunit@gmail.com Banned

    Messages:
    231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    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

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    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