Getting value of a cell from google docs spreadsheet into javascript

后端 未结 3 1159
不知归路
不知归路 2020-12-11 18:01

I have a javascript function

function calculate() {
  var interestRate=4.5;
  ...
}

I would like the interestRate to come from a cell in a

3条回答
  •  不知归路
    2020-12-11 18:31

    First of all, what i would recommend is to "Get a link to Published Data" as csv, as it is just 1 field so you don't have to parse it. If made this spreadsheet, and make a link with "Get a link to Published Data", this second link will get a csv with just one field in this case. You will be able to get this with the following js code (note i'm using jQuery)

    $.ajax("https://docs.google.com/spreadsheet/pub?key=0Auwt3KepmdoudE1iZFVFYmlQclcxbW85YzNZSTYyUHc&single=true&gid=0&range=b5&output=csv").done(function(result){
        alert(result);
    });
    

    Regards

    EDIT: The full code

    
    
        
            
        
        
            
        
    
    

提交回复
热议问题