[{"id":"b66f8b1e-cc14-4e89-9679-abd5687d283d","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"569bb90a-ea68-46c6-96f1-ab151c120714","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5eb52f08-2d1a-4362-9ffc-4871bdc10f3f","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"341dd607-b97d-4d70-bde2-53acda6b6c95","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"05349273-414f-4208-9ea2-c4fc8f4ea2cb","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"86089f76-b778-4d52-821e-6f27de3df613","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b81e4fd6-1fc5-43a0-a258-b6e16a5cbec6","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8aa8ce31-43e4-438e-951f-241608435260","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"37343f41-6ec2-4c7e-b21d-2cc18d5ce1e0","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5915e52f-64f8-4146-b8bd-81bead6324a3","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"836ba889-af9e-460d-a4cc-c24d922795f2","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4ae14b06-bb68-4394-a210-a46b8f028346","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d8f42066-e9dc-4411-bdcf-43b1a203370c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"7ef86f16-b1a0-49f7-9592-612b9be02b25","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b29c7775-a9a4-451e-a1b5-01d19ed5ca5e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"e56f3989-8f81-46af-90fa-a4813eeb976f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"2526c963-f170-45a8-923e-91b0712a9810","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"24575cf0-501a-44f9-8426-c40f8f4b5552","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1a6f8d7f-acd6-42be-8c4f-f464c6218381","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"82b176fd-5cab-498c-909e-8fa7d29c38d8","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1708b3a9-4f37-44a8-8f0e-f9a2d2e5d940","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"c9ac246e-29fb-4bc4-8231-8439795bb590","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"94f2a5c3-2539-436a-af75-23fbbd1a3957","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d99594f4-2d40-4df4-9419-ba2ca6aa3f7f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"fd66e72d-0f10-4f57-9807-6db26290ab2e","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8f344863-503d-4bc3-a594-3815e7d55f5c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"9be82601-de9d-4c18-948a-23ab6f4dd431","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"6495f3c0-b463-47e0-b08a-ca949672211e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b4bede08-3f08-4839-ba4a-abc7ac195bde","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4afcdfc0-3ff5-4f2b-a223-f8fc042a5bbe","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"422062c4-fa40-4771-a86f-008efe6d86e5","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d87e8013-86a7-4840-8d25-6f62e14eb4ac","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a6acedfd-4043-4c64-a5d1-aec3326df9e7","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"dbdc0b24-06c4-48b9-8d6c-7455119dc773","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a3856849-954a-4cfc-96a6-382e530d3638","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4a39306b-ffa5-433d-80a3-28e41f929b72","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]}]
        
(Showing Draft Content)

公式中的单元格引用

公式可以引用常量值或单元格引用。 如果任何引用的单元格中的值发生变更,则公式的结果将变更。 如果您在公式中使用常量值而不是对单元格的引用,则仅当您修改公式(或公式中的值)时,结果才会变更。

使用 SpreadJS, 您可以使用将特定的单元格范围转换为公式字符串 formulaToRanges() 方法。 例如-从行号和列号返回“ A1”地址。

有关在公式中使用单元格引用的更多信息,请参阅 单元格引用的示例代码

如果在公式中的单元格区域之前或之后添加新行,则该范围不包括新行。

以下主题描述了不同的标记样式和引用类型:

A1 表示法

每个单元格可以通过其列字母(A到Z,然后AA到ZZ,AAA到ZZZ,等等)和行号(1或更大)的组合来引用,总共2147483483648行和列。 例如,D50指的是D列和第50行的交点处的单元格。要引用某个单元格范围,请在该范围的左上角输入该单元格的引用,并输入冒号(:),然后 范围右下角对单元格的引用。

R1C1 表示法

每个单元格可以通过其行和列编号来引用,方法是在每个行之前加上字母“ R”(对于行)和字母“ C”(对于列)。 例如,R1C3是第一行和第三列中的单元格。

A1 Cell Ref.

R1C1 Cell Ref.

描述

B12

R12C2

第二列(B列)和第十二行(第12行)中的单元格

D14:D48

R14C4:R48C4

第四列(D列)和第14至48行中的单元格范围

E16:H16

R16C5:R16C8

第五列至第八列(E列至H列)第十六行(第16行)中的单元格范围

A25:E70

R25C1:R70C5

前五列(第A到E列)和第25到70行的单元格范围

相对和绝对

相对单元格引用是相对于具有公式的单元格位置的单元格引用。 绝对引用是一种单元格引用,它始终通过其在图纸中的确切位置来引用单元格,而不是引用当前单元格。

相对引用在复制时会自动调整,而绝对引用则不会。 小部件可以使用绝对或相对单元格引用。 您可以使用ReferenceStyle属性为每个表单定义单元格引用样式。 该公式不支持同时包含绝对和相对行或列引用的范围引用。 换句话说,范围引用中的开始行和结束行必须匹配(绝对值或相对值都必须匹配)。 下表包含公式中有效相对单元格引用的示例。

函数

描述

SUM(A1:A10)

对第一列中的1至10行求和

PI( )*C6

将pi乘以单元格C6中的值

(A1 + B1) * C1

将前两个单元格中的值相加,然后将结果与第三个单元格中的值相乘

IF(A1>5, A12, A13)

检查单元格A1的内容是否大于5,如果是,则将单元格A1的内容乘以2,否则将单元格A1的内容乘以3

对于A1表示法,请在行或列(或两者)之前使用美元符号($)表示绝对引用。 例如

$A$1

绝对第一列,绝对第一行

$A1

第一列绝对值,相对行加一

A$1

相对列加一,绝对第一行

A1

相对列加一,相对行加一

对于R1C1表示法,请在行号或列号(或两者)前后使用方括号[]表示相对引用。 例如

R1C1

绝对第一行,绝对第一列

R1C[1]

绝对第一行,相对列加一

R[1]C1

相对行加一,绝对第一列

R[1]C[1]

相对行加一,相对列加一

R[-1]C[-1]

相对行减一,相对列减一

在此符号中,括号内的数字是当前单元格的偏移量。 此数字可以是负数或正整数或零。 完全消除偏移量是指示零偏移量的简便方法。 所以,

  • RC2等效于R [0] C2

  • R[3]C等效于R [3] C [0]

动态引用

SpreadJS 提供了 dynamicReferences 标志,用于在使用与计算相关的公式函数时实现最小的内存占用和更好的性能。启用此标志后,跨工作表使用公式函数的计算过程将变得更快。

dynamicReferences 标志接受布尔值,用于启用或禁用 CalcEngine 的动态引用模式。这有助于提高诸如 IFCHOOSESUMIFSUMIFSAVERAGEIFAVERAGEIFSMAXIFSMINIFSCOUNTIFSVLOOKUPHLOOKUP 等公式函数的性能。

默认情况下,dynamicReferences 标志的值为 true。如果需要进一步提高计算性能,可以将该标志设置为 false

注意:需要在设置公式或调用 fromJSON 方法之前设置 dynamicReferences 标志。

以下代码片段展示了当 dynamicReferences 选项设置为 falsetrue 时,循环引用的行为如何受到影响。

spread.options.dynamicReferences = false;
spread.options.iterativeCalculation = false;
sheet.setFormula(0, 1, '=SUMIF(A:A,"a*",B:B)');
sheet.setValue(1, 0, "aaa");
sheet.setValue(1, 1, 123); // Here, formula B1 result won't change. Because B1 have listener of A:A, B:B, it's circular reference and iterativeCalculation is false.

spread.options.dynamicReferences = true;
spread.options.iterativeCalculation = false;
sheet.setFormula(0, 1, '=SUMIF(A:A,"a*",B:B)');
sheet.setValue(1, 0, "aaa");
sheet.setValue(1, 1, 123); // Here, formula B1 result will change. Because B1 have listener of A:A, B2, not B:B, it's not circular reference, can calculate when the iterativeCalculation is false