mio*_*odf 5 google-sheets google-apps-script google-drive-api
实现此目的的基本方法是将文件上传到 Google 云端硬盘时打开转换。
\n\n另一种方法是选择文件夹中的xls文件,然后手动逐个转换。
\n\n但是,如果一个文件夹中已经上传了许多 xls 文件,则使用 Google Apps 脚本转换它们可能比再次重新上传文件更快。
\n\n就我而言:
\n\n提前致谢;)
\n该服务必须在使用前启用,但文档非常清楚。
(对不起,耽误了这么久,我忘记了这篇文章)
此代码会将驱动器中的每个 XLS 文件转换为 Google 电子表格格式(只要其名称具有 .xls 扩展名)
您必须授权 Drive 扩展资源 + API 控制台(按照资源/高级服务菜单中的说明进行操作,请参见下图)
function importXLS(){
var files = DriveApp.searchFiles('title contains ".xls"');// you can also use a folder as starting point and get the files in that folder... use only DriveApp method here.
while(files.hasNext()){
var xFile = files.next();
var name = xFile.getName();
if (name.indexOf('.xls')>-1){ // this check is not necessaey here because I get the files with a search but I left it in case you get the files differently...
var ID = xFile.getId();
var xBlob = xFile.getBlob();
var newFile = { title : name+'_converted',
key : ID
}
file = Drive.Files.insert(newFile, xBlob, {
convert: true
});
}
}
}
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
5687 次 |
| 最近记录: |