【问题标题】:Can we create google spreadsheet having multiple sheets by using Google Drive API我们可以使用 Google Drive API 创建具有多张工作表的 Google 电子表格吗
【发布时间】:2016-07-06 09:35:58
【问题描述】:

目前,我们正在使用 DriveService 创建电子表格。它使用单张纸创建电子表格。使用的代码如下:

DriveService service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = applicationName }); 
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = uploadSpreadsheetRequest.FileName;
body.Description = uploadSpreadsheetRequest.FileName;
body.MimeType = "text/csv";
byte[] byteArray=System.IO.File.ReadAllBytes(uploadSpreadsheetRequest.FilePath);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/csv");
request.Convert = true;
request.Upload();

有什么方法可以修改我的代码来创建一个包含多张工作表的电子表格。

我可以通过使用 Google Sheets API 来做到这一点,但我希望通过使用字节来实现。

有人可以帮我解决这个问题吗?

【问题讨论】:

  • 我不这么认为。请注意,您可能想查看 Google Drive api 的 V3 没有理由真正使用旧版本。

标签: c# google-sheets google-drive-api google-spreadsheet-api google-sheets-api


【解决方案1】:

我能够解决这个问题。我使用NPOI 创建具有多张工作表的 excel 文件,然后通过将内容类型设置为 'application/vnd.ms-excel' 使用谷歌驱动器上传该文件。

使用 NOPI,因为 Microsoft Excel 未安装在生产服务器上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-22
    • 2012-09-26
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    相关资源
    最近更新 更多