我可以按名称而不是索引来引用 Smartsheet 列吗?

Can I reference a Smartsheet column by name instead of index?

我有一个智能 sheet 集成,我通过 Web 服务从另一个程序获取数据并写入 sheet。填充 sheet 的相关代码在这里:

         Cell[] cellsA = new Cell[] 
         { 
         new Cell.AddCellBuilder(sheet.Columns[0].Id, projectData[i][0].Trim()).Build()                   //Project ID
         ,new Cell.AddCellBuilder(sheet.Columns[1].Id, projectData[i][1].Trim()).Build()                  //Customer
         ,new Cell.AddCellBuilder(sheet.Columns[2].Id, projectData[i][2].Trim()).Build()                  //Description
         ,new Cell.AddCellBuilder(sheet.Columns[3].Id, projectData[i][3].Trim()).Build()                  //Status
         ,new Cell.AddCellBuilder(sheet.Columns[4].Id, startDate).SetStrict(false).Build()                //StartDate
         ,new Cell.AddCellBuilder(sheet.Columns[5].Id, endDate).SetStrict(false).Build()                  //EndDate
         ,new Cell.AddCellBuilder(sheet.Columns[6].Id, projectData[i][6].Trim()).Build()                  //Project Manager
         };
         // Specify contents of first row.
         Row rowA = new Row.AddRowBuilder(null, true, null, null, null).SetCells(cellsA).Build();

我的问题是,而不是使用

sheet.Columns[0].Id

是否可以使用列名而不是索引来标识特定列?原因是如果用户移动或重新排列列,这将导致错误(日期格式等)。

谢谢...

您不能以编程方式按名称引用列(即使可以,您可能不想这样做 — 因为名称可能会更改,就像位置一样),但您可以以编程方式按 ID 引用列 (这永远不会改变,即使该列被移动或重命名也是如此。