我目前正在创建一个脚本,可以将从 gdrive 文件夹存储的 xlsx 文件导入到电子表格中,我是否可以知道是否有人有我可以探索的参考或示例我已经做了一些研究,但其中一些正在 CSV 过程中。
Firstly:这不是一些赠品服务。如果没有代码示例和具体问题,我们无法提供帮助。
但我有这个可以帮助你开始。启用高级驱动器服务。诀窍是首先转换为工作表,然后获取数据。
function getExcelData() {
//The excel file id -> Open with spreadsheetApp and copy the id from url
const excel = DriveApp.getFileById("excelfileif");
//ID of the folder where the tempfile can be placed.
const tempFolder = "tempFolderId"
const tempFile = Drive.Files.insert(
{title: "TempFile", parents: [{"id": tempFolder}]},
excel.getBlob(),
{convert: true}
);
const tempID = tempFile.getId();
const source = SpreadsheetApp.openById(tempID);
//The sheetname of the excel where you want the data from
const sourceSheet = source.getSheetByName("sheetname");
//The range you want the data from
const sourceValues = sourceSheet.getRange("A1:G20").getValues();
const target = SpreadsheetApp.getActiveSpreadsheet();
//The targetsheetname
const targetSheet = target.getSheetByName("TargetSheetName");
targetSheet.getRange(targetSheet.getLastRow()+1, 1, sourceValues.length, sourceValues[0].length).setValues(sourceValues);
DriveApp.getFileById(tempID).setTrashed(true);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)