public static async Task <UploadSheetTransaction> CreateUploadSheetAsync(SheetsService service, string spreadsheetId, string sheetTitle, ILogger logger) { var spreadsheetAccess = new SpreadsheetAccess(service, spreadsheetId, logger); var spreadsheetResource = service.Spreadsheets.Get(spreadsheetId); var spreadsheetInfo = await spreadsheetResource.ExecuteAsync(); var sheet = spreadsheetInfo.GetSheet(sheetTitle); return(new UploadSheetTransaction(spreadsheetAccess, sheet)); }
public UploadSheetTransaction(SpreadsheetAccess spreadsheetAccess, SheetProperties sheet) { this.requestBuilder = spreadsheetAccess.CreateBatchRequestBuilder(); this.sheetId = sheet.SheetId.Value; var deleteRange = this.requestBuilder.AddDeleteRange(this.sheetId); deleteRange.Range.StartRowIndex = 1; deleteRange.Range.EndRowIndex = sheet.GridProperties.RowCount - 1; var cellsUpdater = this.requestBuilder.AddUpdateCells(this.sheetId); this.firstRow = cellsUpdater.Rows.AddRow(); this.appender = this.requestBuilder.AddAppendCells(this.sheetId); this.requestBuilder.AddAutoResizeDimensions(this.sheetId); this.spreadsheetAccess = spreadsheetAccess; }