使用C#在新工作表中将CSV上传到Google电子表格

时间:2017-04-14 15:08:19

标签: c# google-sheets-api

我可以使用下面的代码通过Sheets API为已经存在的Google电子表格添加新工作表。如何从CSV导入此新工作表?

//Auth code to sheets API above this line
SheetsService sheetsService = new SheetsService(bc_init);
                string spreadsheetID = "XXXXXX";
                string sheetName = DateTime.Now.ToString();

                var addSheetRequest = new AddSheetRequest();
                addSheetRequest.Properties = new SheetProperties();
                addSheetRequest.Properties.Title = sheetName;

                BatchUpdateSpreadsheetRequest batchUpdateSpreadsheetRequest = new BatchUpdateSpreadsheetRequest();
                batchUpdateSpreadsheetRequest.Requests = new List<Request>();
                batchUpdateSpreadsheetRequest.Requests.Add(new Request
                {
                    AddSheet = addSheetRequest

                });
                var batchUpdateRequest = sheetsService.Spreadsheets.BatchUpdate(batchUpdateSpreadsheetRequest, spreadsheetID);
                batchUpdateRequest.Execute();

0 个答案:

没有答案