0
在某一點,我需要通過C#SDK重置上的Smartsheet的數據(到NULL)(NuGet包)Smartsheet SDK(2.0)API - 白天清除細胞
這裏的一個原型代碼代碼段
// Connect tp Smartsheet API
SmartsheetClient ss = new SmartsheetBuilder().SetAccessToken(myAccessToken).Build();
// Load in the Sheet
Sheet sheet = ss.SheetResources.GetSheet(mySheetID, null, null, null, null, null, null, null);
// Get the row/cell we want to update
Row dataRow = sheet.Rows[0];
Cell dataCell = dataRow.Cells[9];
UpdateRowBuilder rb = new Row.UpdateRowBuilder(dataRow.Id);
//
// SET THE VALUE OF THE CELL HERE
//
List<Cell> resetCells = new List<Cell>();
resetCells.Add(new Cell.UpdateCellBuilder(dataCell.ColumnId, null).Build());
// Save the Sheet
ss.SheetResources.RowResources.UpdateRows(mySheetID, new List<Row>() { rb.SetCells(resetCells).Build() });
如果我的單元格的值設置爲一個(字符串)的值,則所有是非常愉快和片材保存,並且該值出現
但是,如果我的值設置爲NULL然後我得到一個例外...
Smartsheet.Api.InvalidRequestException: Required object attribute(s) are missing from your request: cell.value.
at Smartsheet.Api.Internal.AbstractResources.HandleError(HttpResponse response)
at Smartsheet.Api.Internal.AbstractResources.PutAndReceiveList[T,S](String path, T objectToPut, Type objectClassToReceive)
at Smartsheet.Api.Internal.SheetRowResourcesImpl.UpdateRows(Int64 sheetId, IEnumerable`1 rows)
at LHRMayfly.LHRMayFly_Processor.Reset() in C:\Projects\SmartSheetProcessor.cs:line 173
所以,底線的問題是...你如何刪除單元格值?
在回答討論時,您可以簡單地添加一個ClearCell(dataCell.ColumnId)方法 –
...並感謝您的答案......按預期工作 –