0

I'm able to display results and search for data from spreadsheet which has only one sheet. Using od6 as JSON URL : var url = "https://spreadsheets.google.com/feeds/list/153Obe1TdWlIPyveZoNxEw53rdrghHsiWU9l-WgGwCrE/od6/public/values?alt=json";

My requirement is to fetch JSON feed from multiple sheets like blow URL's //var url1 = "https://spreadsheets.google.com/feeds/list/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/2/public/values?alt=json"; // I tried with one URL sheet but still not able to display can you please help //var url2 = "https://spreadsheets.google.com/feeds/list/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/3/public/values?alt=json";

<html>
    <head>


<script src="menu.js"></script>      
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script>
    // Json file : https://spreadsheets.google.com/feeds/worksheets/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/public/basic?alt=json

// code for displaying the data in tabs
 // Json file : https://spreadsheets.google.com/feeds/worksheets/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/public/basic?alt=json

function openPage(pageName,elmnt) {
  var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablink");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].style.color = "#969595";

  }

  document.getElementById(pageName).style.display = "block";
  elmnt.style.color = "white";

}


    //angular js code to display search in JSON URL data

   var app= angular.module('sample', []);
 app.controller('sampleController', function ($scope, $http) {              
   var url = "https://spreadsheets.google.com/feeds/list/153Obe1TdWlIPyveZoNxEw53rdrghHsiWU9l-WgGwCrE/od6/public/values?alt=json";
     //var url1 = "https://spreadsheets.google.com/feeds/list/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/2/public/values?alt=json"; // Using url1 instead of url is not working
     //var url2 = "https://spreadsheets.google.com/feeds/list/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/3/public/values?alt=json";
    //var url = "https://spreadsheets.google.com/feeds/cells/1OJX_UfZ7KQ-NMKcpXmYT8Ml1OfzerPnmUyEcSoMqeZc/1/public/values?alt=json"; // url for sheet1

    $http.get(url)
    .success(function(data, status, headers, config) {     
         $scope.users = data.feed.entry;
         //console.log($scope.users);
    })
    .error(function(error, status, headers, config) {
         console.log(status);
         console.log("Error occured");
    }); 
   app.filter('highlightFilter', $sce =>
 function (element, searchInput) {
   element = element.replace(new RegExp(`(${searchInput})`, 'gi'),
             '<span class="highlighted">$&</span>');
   return $sce.trustAsHtml(element);
 });
    $scope.search='';
    $scope.searchFilter=function(item){

        if(item.gsx$topic.$t.toLowerCase().indexOf($scope.search.toLowerCase()) != -1 || item.gsx$response.$t.toLowerCase().indexOf($scope.search.toLowerCase()) != -1){
        // code to highlight

      // code to highlight
        return true;

            }
      return false;
    }

});   


</script>


    </head>
<body>


<div ng-app="sample"  ng-controller="sampleController">



  <input type="text" name="search" ng-model="search" placeholder="Search in all sheets" ></input>

    <br>
    <br>
  <table  style="border: 1px solid black ;" >
    <tbody>
        <tr>
            <td style="color:blue; font-size:14px;"><center><b>Question</b></center></td>
            <td style="color:blue; font-size:14px;"><center><b>Response</b></center></td>
        </tr>
      <tr ng-repeat="user in users | filter:searchFilter">
        <td style="border: 1px solid black ; width:30%;white-space: pre-wrap;">{{user.gsx$topic.$t}}</td>
        <td style="border: 1px solid black ; width:70%;white-space: pre-wrap;">{{user.gsx$response.$t}}</td>
      </tr>
    </tbody>
  </table>

</div>
</body>
</html>
3
  • Hello @TejoSaiKumarEEPU, are you getting any errors? Cheers! Commented Jan 31, 2020 at 10:47
  • Hi @ale13 I'm getting below error while using url1. Also my requirement is to get data and display from all sheets with sheet names. can you help? Error : userCodeAppPanel:1 Access to XMLHttpRequest at CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Commented Feb 3, 2020 at 6:00
  • can someone help with this error? I have used http.get(url1) and http.get(url2) and so on.. to access multiple sheets data and I'm getting the data from my personal G-sheet. But not able to get from the original file that is from my corporate account. Commented Feb 7, 2020 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.