user1554754
user1554754

Reputation: 135

Exporting From Google Spreadsheet To XML

I have a google docs spreadsheet and an XML file which is made on the base of this spreadsheet. What I need right now is a way to speed up exporting information to XML format. So I've turned to google scripts.

I can currently retrieve certain cells from a spreadsheet and make string variables, however I need to save the resulting strings to an XML file using minimum amount of clicks.

Is there any way to instantly make an xml file using google scripts and send it to download from the browser? The only way to save the result I've found is creating a plain text document in google drive folder, opening this document and manually copypasting it's content to my xml file. But it seems that this plain text documents do not understand tab-characters (\t) and I kinda need them to make a certain structure in my xml.

Upvotes: 9

Views: 28180

Answers (2)

mzimmerman
mzimmerman

Reputation: 940

ContentService will allow you granular control over what exactly you want the XML to look like. You can also let Google create the XML Atom/RSS feed for you by publishing your sheet.

In the Old Sheets, the Publish option allowed XML export. (No longer supported.) Here's a sample of the XML.

Upvotes: 1

Ikai Lan
Ikai Lan

Reputation: 2240

Have you looked into Content Service? You would generate the XML and serve it via Content Service, set the XML mime-type, then use downloadAsFile to tell the browser to just download the file instead of displaying it.

Upvotes: 6

Related Questions