C# 如何上传Excel文件并以编程方式将其转换为Google电子表格?

C# 如何上传Excel文件并以编程方式将其转换为Google电子表格?,c#,google-apps-script,google-drive-api,google-spreadsheet-api,C#,Google Apps Script,Google Drive Api,Google Spreadsheet Api,我正在编写与谷歌电子表格交互的桌面程序,为此我需要上传excel表格,并通过编程方式将其转换为谷歌电子表格。我检查了谷歌硬盘,谷歌电子表格API找不到这样做的方法。如果有人能提出任何一种方法来做到这一点,这将是一个巨大的帮助 这是我现在的代码,它正在正确上传excel文件,但它并没有转换成谷歌电子表格 Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();

我正在编写与
谷歌电子表格
交互的桌面程序,为此我需要上传
excel表格
,并通过编程方式将其转换为
谷歌电子表格
。我检查了谷歌硬盘,谷歌电子表格API找不到这样做的方法。如果有人能提出任何一种方法来做到这一点,这将是一个巨大的帮助

这是我现在的代码,它正在正确上传excel文件,但它并没有转换成谷歌电子表格

            Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
            body.Title = "My document";
            body.Description = "A test document";
            body.MimeType = "application/vnd.ms-excel";

            byte[] byteArray = System.IO.File.ReadAllBytes("test.xlsx");
            System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);

            FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "application/vnd.google-apps.spreadsheet");
            request.Convert = true;
            request.Upload();

            Google.Apis.Drive.v2.Data.File file = request.ResponseBody;
            Console.WriteLine("File id: " + file.Id);
            Console.WriteLine("Press Enter to end this process.");
            Console.ReadLine();

我使用了驱动API,下面是我用来转换XLS文件的代码片段

function convert(xlsxFileId, name) { 
  var xlsxBlob = xlsxFileId;
  var file = {
    title: name,
    //Which Drive Folder do you want the file to be placed in
    parents: [{'id':'FOLDER_ID'}],
    key: 'XXXX',
    value: 'XXXX',
    visibility: 'PRIVATE'
  };

  file = Drive.Files.insert(file, xlsxBlob, {
    convert: true
  });
}

如果没有帮助,可能会重复,您需要发布当前用于上载到Google drive的代码。谢谢您的评论,我已经添加了代码。这是Google应用程序脚本吗?是的,但drive是一项扩展服务,必须为该项目激活。进入脚本编辑器中的资源菜单并按照说明进行操作。感谢您的评论,我需要使用C从客户端进行转换#