The script provided seems to work, but it posts the data to the first sheet tab of the spreadsheet, when I'd like to have it post on a sheet entitled XML.
I've tried changing getActiveSheet() to getSheetByName("XML") and a number of other things but have had no luck. Any ideas?
function getData() {
var queryString = Math.random();
var cellFunction1 = '=IMPORTXML("http://www.resources-game.ch/exchange/kurseliste.xml?' + queryString + '","//RESOURCES_RATES/ITEM")';
SpreadsheetApp.getActiveSheet().getRange('A1').setValue(cellFunction1);
}
Change this line:
SpreadsheetApp.getActiveSheet().getRange('A1').setValue(cellFunction1);
to this:
SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName('XML').getRange('A1')
.setValue(cellFunction1);
I added getActiveSpreadsheet() which is different than getActiveSheet(). There is also a getActive() method which gets a spreadsheet. So, both getActive() and getActiveSpreadsheet() do the same thing. They get the spreadsheet, not a sheet. I've confused those 3 methods before.
getActive() - gets spreadsheetgetActiveSpreadsheet() - gets spreadsheetgetActiveSheet() - gets sheet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With