将文件夹中所有可用的 xls 文件转换为“Google Doc Spreadsheets"? [英] Convert all xls files available in a folder into "Google Doc Spreadsheets"?

查看:16
本文介绍了将文件夹中所有可用的 xls 文件转换为“Google Doc Spreadsheets"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行此操作的基本方法是在将文件上传到 Google 云端硬盘时开启转换.

The basic way to do that is turn conversion on when uploading files into Google Drive.

另一种方法是选择文件夹中的xls文件,然后手动一个一个地进行转换.

Another way is to select the xls file in the folder and convert it one by one by hand.

但如果一个文件夹中已经上传了许多 xls 文件,使用 Google Apps 脚本转换它们可能比重新上传文件更快.

But if one has already many xls files uploaded in a folder, it may be faster to convert them with Google Apps Script than re-uploading again the files.

就我而言:

  • 转换后,我需要删除 xls 文件
  • 所有 xls 文件都低于限制:已上传的转换为 Google 电子表格格式的电子表格文件不能大于 100 MB,并且需要少于 400,000 个单元格和每工作表 256 列."https://support.google.com/drive/answer/37603?hl=en

提前致谢;)

推荐答案

你应该使用 高级云端硬盘服务文件更新

此服务必须在使用前启用,但文档很清楚.

This service must be enabled before use but the doc is pretty clear.

(抱歉耽误了这么久,我忘记了这个帖子)

此代码会将您驱动器中的每个 XLS 文件转换为 Google 电子表格格式(只要它们的名称具有 .xls 扩展名)

This code will convert every XLS files in your drive to Google spreadsheet format (as long as their names have an .xls extension)

您必须授权 Drive 扩展资源 + API 控制台(按照资源/高级服务菜单中的说明进行操作,参见下图)

You must authorize the Drive extended ressource + API console (follow the instructions from the ressource/advanced services menu, see illustration below)

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
      });
    }
  }
}

这篇关于将文件夹中所有可用的 xls 文件转换为“Google Doc Spreadsheets"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆