我有一个带有链接附件的智能表。我想用其他子字符串替换链接的开头。我是smartsheet的新手,却找不到太多示例代码。
表格设置
SmartsheetClient smartsheet = new SmartsheetBuilder().SetaccessToken(accessToken).Build();
paginatedResult<Sheet> sheets = smartsheet.SheetResources.ListSheets(
null,// IEnumerable<SheetInclusion> includes
null,// PaginationParameters
null // Nullable<DateTime> modifiedSince = null
);
long sheetId = (long)sheets.Data[1].Id; //get first sheet's ID
//get sheet associated with sheetId
Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId,null,null);
在这里,我正在尝试创建包含必须更改的链接的行列表,
List<Row> rowsToUpdate = new List<Row>();
foreach (var row in sheet.Rows)
{
Row rowToUpdate = null;
var cellsToUpdate = new List<Cell>();
var at = row.Attachments;
string toReplace = "http://blahblah/blah";
string newValue = "https://hello/";
foreach(var attachment in row.Attachments)
{
var url = attachment.Url;
var id = attachment.Id;
if (url!=null && url.Contains(toReplace)){
var newUrl = url.Replace(toReplace,newValue);
}
}
//create new cell that will contain updated links
var cellToUpdate = new Cell {
ColumnId =,//is it possible to get Attachments column Id?
Value = //add updated links here?
};
cellsToUpdate.Add(cellToUpdate);
//this will be added to the list rowsToUpdate
rowToUpdate = new Row {
Id = row.Id,Cells = cellsToUpdate
};
}
smartsheet.SheetResources.RowResources.UpdateRows(sheet.Id.Value,rowsToUpdate);
我尝试获取“附件”列ID,但是此方法不起作用,因为我认为这是主列(?)
var columns = smartsheet.SheetResources.ColumnResources.ListColumns(sheetId,null).Data;
var attachmentCol = columns[0].Title;
谢谢您的帮助。