0

I have a excel sheet which has around 5000 rows in it.I have used JavaScript API to view the location coloumn in my webpage.User can also query the results from my webpage using SQL API.Now I want to display those query results not only in map also as a table in my webpage.How to do it?

7783
  • 373
  • 4
  • 8
  • 27

2 Answers2

0

Use the Visualization API.

Chris Broadfoot
  • 5,082
  • 1
  • 29
  • 37
0

I believe the Visualization API has a 500 row limit. Another alternative is to use Fusion Table's JSONP support. I posted some example code in these SO answers:

https://stackoverflow.com/a/10343112/1211981

https://stackoverflow.com/a/9778985/1211981

UPDATE:

Here's an example link which lets a user download a FT as a CSV. It's a bit long and URL encoded for display in a web page.

https://www.google.com/fusiontables/api/query?sql=SELECT%20program,platform,observables,obs_url%20FROM%202796211%20WHERE%20%27program%27%20=%20%27NERACOOS%27%20and%20%27data_provider%27%20=%20%27LISICOS%27

And some code showing how to do it. Assuming your where clause is correct.

    var queryUrlHead = 'https://www.google.com/fusiontables/api/query?sql=';
    var qry = "SELECT * FROM " + table_id " WHERE " + where;

    var enc_qry = encodeURI(queryUrlHead + qry);

    var csv_link = '<a target="_new" href="' + enc_qry + '">Download as CSV</a><br />';
    // this is jQuery
    $("#csv_link").text('');
    $("#csv_link").append(csv_link);
Community
  • 1
  • 1
Eric Bridger
  • 3,751
  • 1
  • 19
  • 34
  • thanx eric.How to save that resultant table from my webpage as a excel sheet. – 7783 May 04 '12 at 06:52
  • I don't understand this question. The Fusion Table response is already CSV and includes columns names and data rows. That is excel compatible. – Eric Bridger May 04 '12 at 09:44
  • Just i want to know how to download the result of a query in my page as excel data. – 7783 May 04 '12 at 10:31
  • i use google visualization to show datas from fusion table into my webpage.users can query the fusion table from my webpage.i need to save the query results as excel sheet or save as excel option. – 7783 May 04 '12 at 11:18
  • I understand now. I have an application does just this as one option. I've updated my answer to show it. – Eric Bridger May 04 '12 at 20:16
  • Please do not use the undocumented JSONP endpoint. It may go away or break in unexpected ways sometime in the future. – Chris Broadfoot May 04 '12 at 20:32
  • Good point broady. The above examples will working using www.google.com – Eric Bridger May 05 '12 at 15:08