Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Spread.Sheets supports array formulas.
Use 支持数组函数。
使用 Ctrl + Shift + Enter to create an array formula after entering the formula at run time if the users are allowed to create formulas, or you can use the setArrayFormula method.
Array formulas are supported when exporting or importing to Excel-formatted files and JSON objects.
Array formulas have the following limitations:

  • Array formulas are not supported in ranges that contain merged cells.
  • The formula cannot be changed in part of the range.
  • Cut and copy applies to the entire range.
  • Columns and rows cannot be inserted or removed from part of the range.

Using Code
This example uses the setArrayFormula method.或者 setArrayFormula 方法来创建一个数组函数。

数组函数支持导出 Excel 文件或者 JSON 格式的数据。

但是 Spread.Sheets 中的数组函数有如下限制:

  • 数组函数不支持有合并单元格的区域。
  • 被设置为数组函数的单元格区域内单元格的公式不能更改。
  • 复制和粘贴将会影响到整个单元格区域。
  • 在设置为数组函数的区域中不能插入行和列。

示例代码

以下代码使用了 setArrayFormula 方法。

JavaScript

Copy Code

activeSheet.getCell(1,1).value(3);activeSheet.getCell(2,1).value(1);activeSheet.getCell(3,1).value(3);activeSheet.getCell(4,1).value(7);activeSheet.getCell(1,2).value(7);activeSheet.getCell(2,2).value(7);activeSheet.getCell(3,2).value(7);activeSheet.getCell(4,2).value(7);spread.options.allowUserEditFormula = true;activeSheet.setArrayFormula(0, 3, 4, 1, "B2:B5*C2:C5");

 

See Also另见
Formula Reference