介绍自定义JDataGrid电子表格版本公式中的函数?
2019獨角獸企業重金招聘Python工程師標準>>>
How to write function in JDataGrid Spreadsheet Edition?
1. Understand the formula and function API used in JDataGrid Spreadsheet Edition?
Obviously you should understand the “Function” and it’s sub class.
? The central method of Function interface is “Object evaluate(FormulaContext ctx, List args)”, the method have the “FormulaContext” and List based arguments.
? Override the method “evaluate(FormulaContext ctx, List args)” and write your logic in the method body, finally return the result, you can override the AbstractFunction directly or implements the Function interface, don’t forget invoke super(name) when use AbstractFuction.
? Note: The important point need to mention is you should invoke the method “CellUtils.getObject”, “CellUtils.stringValue” to get every argument’s value, this is impossible before the JDataGrid Spreedsheet Edition 2.5.0, since the CellUtils is package private, the developer need copy the “CellUtils” class before the version 2.5.0, the good news is the API now open to public after version 2.5.0.
2. Add the function to the FormulaFactory.
?The FormulaFactory provides the several methods to add or remove the function.
?FormulaFactory.addFunction(Function);
FormulaFactory. removeFunction(String);
FormulaFactory. getAllFunctionNames();
FormulaFactory. getFunction(String);
The function you added will be the CellFunctionType.CUSTOM by default, these functions will be lists in “Custom” category in the choose function dialog, this is a new feature in JDataGrid 2.5.0.
查看原文
--------------------------
新聞: 國際知識產權聯盟公布盜版重點觀察國名單
導航: 博客園首頁?? 知識庫?? 新聞?? 招聘?? 社區?? 小組?? 博問?? 網摘?? 找找看
轉載于:https://my.oschina.net/javastudy/blog/27
總結
以上是生活随笔為你收集整理的介绍自定义JDataGrid电子表格版本公式中的函数?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 王道操作系统考研笔记——2.3.4 信号
- 下一篇: 如何从PDF文件中提取几页为一个PDF文