nautilia
nautilia

Reputation: 75

google visualization table. Insert an image in a cell (from GDocs)

I'm trying to insert a Google Spreadsheet in an html document and show it as a table. So, my source is a Google Docs document and I call it with a query

(var query = new google.visualization.Query).

My table is a list of countries with some data about them. Html visualization until this point is OK.

But I want to add a column with an image (a flag). I don't know if it's possible to do this and, if possible, how to do it.

I've tried to put the link in the cell of the Google Spreadsheet, copy-paste an image, and an img src="...", but no luck. The only thing I have is the code written inside the cell both in the GDocs and the html visualization.

I've defined as an option

(var options = {allowHtml: true};

Any suggestion?

Thank you in advance!

Upvotes: 1

Views: 1875

Answers (1)

oli
oli

Reputation: 3551

This is possible, I'm not sure why your options didn't work.

This is an export to csv from my spreadsheet:

someContent,someImage
catz,<img src='http://1.bp.blogspot.com/-TzV-DfLU7jc/TagrymLT1HI/AAAAAAAABro/q4Jf1xNjxpk/s1600/ghoul.jpg' />

And the relevant javascript code after a call to the spreadsheet:

var data = response.getDataTable();
visualization = new google.visualization.Table(document.getElementById('visualization'));
visualization.draw(data, {allowHtml: true});

As you noted, allowHtml: true is required.

Upvotes: 2

Related Questions