SmartSheet SDK API 中有几个对象是对象的扩展。例如,CellLink 和 ObjectValue 是 Cell 对象的扩展。我已经阅读并了解这些是父/子类并且涉及继承。但是,我仍然无法理解这个概念,我无法弄清楚创建 CellLink 对象的语法。
new_cell = ss.models.Cell()
linked_cell = ss.models.Cell()
linked_cell.column_id = int(columnid)
linked_cell.sheet_id = int(sheetid)
linked_cell.row_id = int(rowid)
new_cell.link_in_from_cell = linked_cell
上面的示例为我提供了最丰富的错误消息,因此,我认为它最接近我尝试过的所有变体的正确语法。对此示例以及可能的基本概念的任何帮助将不胜感激。
raise ValueError("`{0}` invalid type for {1} value".format(value,
self.object_type))
ValueError: `{"columnId": 2068210422966148}` invalid type for <class
'smartsheet.models.cell_link.CellLink'> value
我相信我已经找到了这个问题的答案。似乎您只需要创建一个属性字典,例如:
ex_dict = {sheet_id: 0974792938, column_id: 07263839242, row_id:
2632938474839}
new_cell.link_in_from_cell = ex_dict
诀窍在代码的后面。而不是创建一个新行,如:
row = ss.models.Row()
您需要更新现有行,例如:
row = ss.Sheets.get_row(sheet_id, row_id)
但是,我仍然有一个奇怪的错误:字段“createdAt”是意外类型。