在App Script中将.XLS转换为Google表格的最有效方法是什么? [英] What is the most efficient way to convert a .XLS to Google Sheets in App Script?

查看:46
本文介绍了在App Script中将.XLS转换为Google表格的最有效方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每周自动将.XLS文件下载到Google驱动器.我想每周自动将最新下载的.XLS文件转换为Google表格格式.

I download a .XLS file automatically to a Google drive weekly. I would like to automatically convert the latest downloaded .XLS file every week to Google sheets format.

因此转到特定的Google驱动器文件夹.查找最新的或未转换的.XLS文件.转换为Google表格格式并保存在同一文件夹中.

Thus go to specific Google drive folder. Find the latest or unconverted .XLS file. Convert to Google sheets format and save in the same folder.

推荐答案

  • 您要将一个 .xls 文件转换为Google Spreadsheet.
    • .xls 文件的大小为60 KB.
    • .xls 文件放在特定的文件夹中.
      • You want to convert one .xls file to Google Spreadsheet.
        • The .xls file has 60 kBytes in the file size.
        • The .xls file is put in the specific folder.
        • 如果我的理解是正确的,那么该示例脚本如何?在此示例脚本中, .xls 文件由Drive API v2的files.copy方法转换.

          If my understanding is correct, how about this sample script? In this sample script, the .xls file is converted by files.copy method of Drive API v2.

          使用此脚本时,请在高级Google服务中启用Drive API.

          var folderId = "###"; // Please set the folder ID including the .xls file.
          
          var files = DriveApp.getFolderById(folderId).getFilesByType(MimeType.MICROSOFT_EXCEL_LEGACY);
          if (files.hasNext()) Drive.Files.copy({mimeType: MimeType.GOOGLE_SHEETS, parents: [{id: folderId}]}, files.next().getId());
          

          注意:

          • 该示例脚本用于 .xls 文件.如果要使用 .xlsx 文件,请从 MimeType.MICROSOFT_EXCEL_LEGACY 修改为 MimeType.MICROSOFT_EXCEL .
          • Note:

            • This sample script is for the .xls file. If you want to use .xlsx file, please modify from MimeType.MICROSOFT_EXCEL_LEGACY to MimeType.MICROSOFT_EXCEL.
            • 这篇关于在App Script中将.XLS转换为Google表格的最有效方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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