跳到主要内容

Set

通过索引设置数组值。

备注

此方法不适用于 JS

语法

def Set(self, key: int, value: CDocBuilderValue) -> None

参数

名称类型描述
keyint数组值的索引。
valueCDocBuilderValue要设置的数组值。

示例

builder = docbuilder.CDocBuilder()
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj["Api"]
document = api.GetDocument()
charts = document.GetAllCharts()
chart = api.CreateChart("bar3D", [[200, 240, 280], [250, 260, 280]],
["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016],
4051300, 2347595, 24)
charts.Set(1, chart)

索引运算符

operator[] 后缀表达式也可用于通过索引设置数组值:

array[index] = value