Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 430
user1554754 Avatar asked Jul 26 '12 13:07

user1554754


People also ask

How do I convert XLSX to XML?

How to convert a XLSX to a XML file? Choose the XLSX file that you want to convert. Select XML as the the format you want to convert your XLSX file to. Click "Convert" to convert your XLSX file.

How do I export data from Google Sheets?

Choose tab and export data Under the Export data section, click Select data. As you can see below, our open file is automatically selected. Now, choose the tab you wish to export. In this example, I want to export Garry's performance data, so I'll select his tab.

How do I use XML in Google Sheets?

Open any google spreadsheet and go to Add-ons in the page menu and click on Launch. Click on the XML integration. Add a Name to the XML query and add the XML data source url in the Data Url field. Add a Name to the query and add the XML data source url in the Data Url field.

Can you export a Google Sheet to JSON?

Even better, you can close the spreadsheet, come back to it later, add more data, and export it as JSON (the Apps Script remains associated with the spreadsheet). The one caveat is that when you re-open the spreadsheet, it might take a few seconds for the Export JSON menu to appear.


2 Answers

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.

like image 172
Ikai Lan Avatar answered Sep 21 '22 11:09

Ikai Lan


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.

like image 34
mzimmerman Avatar answered Sep 18 '22 11:09

mzimmerman