In this post, I can use the script to export a sheet from google sheet to a csv file, but that file is saved in my google drive. How can I export it to a network drive? The network drive I mean is that when you open file explorer, and you can search \\Location1\location2\location3
to get to the network drive.
Here is a link to a simple google sheet with the appscript that can export it to a csv file. Here is the script (you can access it in the file as well):
function sheetToCsv()
{
var ssID = SpreadsheetApp.getActiveSpreadsheet().getId();
var sheet_Name = "Sheet1"
var requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet_Name)
var sheetNameId = sheet.getSheetId().toString();
params= ssID+"/export?gid="+sheetNameId +"&format=csv"
var url = "https://docs.google.com/spreadsheets/d/"+ params
var result = UrlFetchApp.fetch(url, requestData);
var resource = {
title: sheet_Name+".csv",
mimeType: "MimeType.csv"
}
var fileJson = Drive.Files.insert(resource,result)
}
How to adapt the code to store the csv file in network location \\Location1\location2\location3
?