【发布时间】:2021-05-20 02:32:47
【问题描述】:
我有此代码可将我的 Google 工作表导出到“CSV”分隔标签“|”感谢@iansedano 的帮助。
这就是脚本:
function createCsvContent(values, delimiter) {
// This converts the values 2D array into a simple array of strings delimited by the delimiter
const stringArray = values.map(row => row.join(delimiter))
// Then it joins all the strings with newlines
const output = stringArray.join("\n")
return output
}
function createCsv() {
// Get all the values from the sheet as a 2D array
const file = SpreadsheetApp.getActive();
const sheet = file.getSheetByName("LIST");
const range = sheet.getDataRange();
const values = range.getValues();
// call the function to create the csv-like content
const csvContent = createCsvContent(values, "|")
// create the file in drive
//DriveApp.createFile('csvFile', csvContent, MimeType.PLAIN_TEXT)
DriveApp.getFileById("[10eI7WAO688nQHRqj7ymscN5I5fJpP4fVTUn_qZMuq3Y]").setContent(csvContent)
}
所以每次运行脚本时,我都想覆盖这个文件https://docs.google.com/document/d/10eI7WAO688nQHRqj7ymscN5I5fJpP4fVTUn_qZMuq3Y/edit。
我无法提交正确的文件 ID。如果我没记错的话,这不是文件 ID '10eI7WAO688nQHRqj7ymscN5I5fJpP4fVTUn_qZMuq3Y'。
我在哪里可以获得 Google Doc 的真实 ID?
【问题讨论】:
标签: google-apps-script google-sheets google-cloud-platform