2017-10-25 5 views
1

행의 들여 쓰기 수준을 1로 설정할 수 없습니다. AddRows 결과는 InvalidRowLocation 예외입니다. 행을 기존 를 업데이트 할 때InvalidRowLocation Smartsheet C#

static string[] DeserializeJson(string json) 
    { 
     try 
     { 
      SortedDictionary<string, string> values = JsonConvert.DeserializeObject<SortedDictionary<string, string>>(json); 
      return new string[] { values["Status"], values["ServerIP"], values["ClientIP"], values["Date"] }; 
     } 
     catch 
     { 
      return new string[] { json }; 
     } 
    } 

    static Row MakeRow(Sheet sheet, string[] values) 
    { 
     List<Cell> cells = new List<Cell>(); 
     Cell cell; 
     IEnumerator<Column> cols = sheet.Columns.GetEnumerator(); 
     DateTime date; 
     for (int n = 0; n < values.Length; n++) 
     { 
      cols.MoveNext(); 
      Column col = cols.Current; 
      if (col.Type == ColumnType.DATE) 
      { 
       date = DateTime.ParseExact(values[n], dateFormat, CultureInfo.InvariantCulture); 
       cell = new Cell.AddCellBuilder(col.Id, DateTime.Now).Build(); 
      } 
      else 
       cell = new Cell.AddCellBuilder(col.Id, values[n]).Build(); 
      cells.Add(cell); 
     } 
     Row row = new Row.AddRowBuilder(null, true, null, null, null).SetCells(cells).Build(); 
     if (values.Length > 1) 
      row.Indent = 1; // Results in an exception 
     return row; 
    } 

    static void AddRows(SmartsheetClient client, Sheet sheet, string[] lines) 
    { 
     List<Row> rows = new List<Row>(); 
     foreach (string line in lines) 
      rows.Add(MakeRow(sheet, DeserializeJson(line))); 
     client.SheetResources.RowResources.AddRows(sheetId, rows); 
    } 

답변

1

Smartsheet에서의 들여 쓰기는 행 사이에 "부모 - 자식"관계를 만듭니다. 새 행을 들여 쓰려면 부모 행의 rowId을 parentId로 지정해야합니다.

그것은이

Row row = new Row.AddRowBuilder(null, true, 7531436244775314, null, null).SetCells(cells).Build(); 
과 같을 것