0

我们必须更新智能表单元格的值。此单元格包含指向不同工作表的超链接。已分配超链接 URL。我们想通过 Smartsheet API C# SDK 更新这个单元格值。

4

1 回答 1

0

如果我正确理解您的方案,则工作表中的单元格包含指向另一个 Smartsheet 工作表的超链接(如此处所述),并且您希望将该单元格值更新为指向 Smartsheet 中不同工作表的超链接。以下代码使用 Smartsheet C# SDK 来完成此操作。

// Replace the second parameter here with your API Access Token
System.Environment.SetEnvironmentVariable("SMARTSHEET_ACCESS_TOKEN", "replace-this-string-with-your-API-access-token");

SmartsheetClient smartsheet = new SmartsheetBuilder().Build();

// Specify updated cell value (hyperlink to another sheet)
var cellToUpdate = new Cell
{
    ColumnId = 6101753539127172,  // ID of the column that contains the cell you're updating
    Value = "text-value-for-hyperlink",  // text value of hyperlink to display in the cell -- typically set to the target Sheet's name
    Hyperlink = new Hyperlink
    {
        SheetId = 7501762300012420  // ID of the sheet that the hyperlink will point to
    }
};

// Identify row and add updated cell object to it
var rowToUpdate = new Row
{
    Id = 4324392993613700,  // ID of the row that contains the cell you're updating
    Cells = new Cell[] { cellToUpdate }
};

// Issue the 'update row(s)' request
IList<Row> updatedRow = smartsheet.SheetResources.RowResources.UpdateRows(
    3932034054809476,    // ID of the sheet that you're updating
    new Row[] { rowToUpdate }
);

希望这会有所帮助。如果我没有正确理解您的情况,请对此答案发表评论,以进一步详细说明您的情况。

**更新 - 用另一种类型的值替换工作表超链接**

请注意,如果要从单元格中删除工作表超链接并将其替换为另一个值,则应Hyperlink在请求中指定一个空对象,如以下代码所示。

// Specify updated cell value (just a text value -- i.e., no longer a sheet hyperlink)
var cellToUpdate = new Cell
{
    ColumnId = 6101753539127172,  // ID of the column that contains the cell you're updating
    Value = "new-cell-value",
    Hyperlink = new Hyperlink()
};
于 2020-12-13T23:39:32.610 回答