自定义函数
您可以在 Collabora Office Calc 中使用以下方式应用自定义函数:
-
您可以使用 Basic-IDE 定义自己的函数。此方法需要有基本的编程知识。
-
您可以将函数编写为add-ins。此方法需要有丰富的编程知识。
使用 Collabora Office Basic 定义函数
-
Choose .
-
You will now see the Basic IDE.
-
In the Object Catalog window, double-click on the module where you want to store your macro.
-
Enter the function code. In this example, we define a VOL(a; b; c) function that calculates the volume of a rectangular solid with side lengths a, b and c:
Function VOL(a, b, c)
VOL = a*b*c
End Function
-
关闭 Basic-IDE 窗口。
Your function is automatically saved in the selected module and is now available. If you apply the function in a Calc document that is to be used on another computer, you can copy the function to the Calc document as described in the next section.
将函数复制到文档
在「使用 Collabora Office Basic 定义函数」的第 2 阶段,在「宏对话框中点击「编辑」。默认情况下,「宏的来源」字段中的「我的宏 - 标准 - Module1」模块处于选中状态。标准」库位于本机的用户目录中。
如果要将自定义函数复制到 Calc 文档中:
-
Choose .
-
在「宏的来源字段中,选择我的宏 - 标准 - Module1」,然后点击「编辑」。
-
在 Basic-IDE 中,选择自定义函数的源代码,并将其复制到剪贴板中。
-
关闭 Basic-IDE。
-
Choose .
-
在「宏的来源字段中,选中 (Calc 文档的名称) - 标准 - Module1」。点击「编辑」。
-
将剪贴版内容粘贴到该文档的 Basic-IDE 中。
在 Collabora Office Calc 中应用自定义函数
Once you have defined the function VOL(a; b; c) in the Basic-IDE, you can apply it the same way as the built-in functions of Collabora Office Calc.
-
Open a Calc document and enter numbers for the function parameters a, b and c in cells A1, B1, and C1.
-
将光标放在另一单元格中,然后输入以下内容:
=VOL(A1;B1;C1)
-
将会计算该函数的值,您可以在选中的单元格中看到结果。