【问题标题】:Smartsheet C# API add row array below first rowSmartsheet C# API 在第一行下方添加行数组
【发布时间】:2016-08-08 15:08:03
【问题描述】:

我正在编写 C# 代码以将数据导入 Smartsheet。我想留下一个虚拟行作为第一行,并在其下方添加所有后续行。我在文档中找不到执行此操作的语法。 AddRows 方法似乎没有任何方法可以确定这一点。这是我的代码:

Cell[] cellsA = new Cell[] 
{ 
new Cell.AddCellBuilder(sheet.Columns[1].Id, taskData[i][1]).Build()                        //summary
,new Cell.AddCellBuilder(sheet.Columns[2].Id, taskData[i][2]).SetStrict(false).Build()         //StartDate
,new Cell.AddCellBuilder(sheet.Columns[3].Id, taskData[i][3]).SetStrict(false).Build()           //DueDate
,new Cell.AddCellBuilder(sheet.Columns[5].Id, taskData[i][4]).Build()                        //Estimated Hrs.
,new Cell.AddCellBuilder(sheet.Columns[6].Id, taskData[i][5]).Build()                        //Completion
,new Cell.AddCellBuilder(sheet.Columns[7].Id, taskData[i][6]).Build()                        //OWner
,new Cell.AddCellBuilder(sheet.Columns[8].Id, taskData[i][7]).Build()                        //Priority
,new Cell.AddCellBuilder(sheet.Columns[9].Id, taskData[i][8]).Build()                        //Status
,new Cell.AddCellBuilder(sheet.Columns[10].Id, taskData[i][9]).Build()                        //Category
,new Cell.AddCellBuilder(sheet.Columns[11].Id, screenURL + taskData[i][0]).Build()           
};

// Specify contents of first row.
Row rowA = new Row.AddRowBuilder(true, null, null, null, null).SetCells(cellsA).Build();

// Add rows to sheet.
smartsheet.SheetResources.RowResources.AddRows(SheetID, new Row[] { rowA });

【问题讨论】:

    标签: smartsheet-c#-sdk-v2


    【解决方案1】:

    在第一行下方添加一行的关键在于创建新行的代码行 - 具体而言,第二个参数确定 ?bool 'toBottom' 属性。示例:

     // Specify contents of first row.
     Row rowA = new Row.AddRowBuilder(null, true, null, null, null).SetCells(cellsA).Build();
    

    【讨论】:

      【解决方案2】:

      我建议先将虚拟行添加到您的工作表中。在响应中,您将获得可以存储以供以后使用的新行 ID。然后,当您向工作表添加新行时,您可以将新行的兄弟 ID 设置为该行 ID,它们将直接出现在该行的下方。

      另一种方法是先添加虚拟行,然后在添加新行时使用 toBottom 设置位置,以便每次将行放置在工作表的底部。有关行位置的更多信息可以在此处的文档中找到: http://smartsheet-platform.github.io/api-docs/?csharp#row-location

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-04-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-16
        相关资源
        最近更新 更多