接上回的回答,您试一下这样做
- $(document).ready(function () {
- var spreadNS = GC.Spread.Sheets;
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- var sheet = spread.getActiveSheet();
- function CustomNumberFormat() {
- }
- CustomNumberFormat.prototype = new GC.Spread.Formatter.FormatterBase();
- CustomNumberFormat.prototype.format = function (obj) {
- //这里写自定义四舍五入的代码,其中参数obj为单元格填入的值,return 的结果是格式化后的显示结果(text)
- return -1.5;
- };
- CustomNumberFormat.prototype.parse = function (obj) {
- //这里将四舍五入的结果进行返回,更改的是value
- return -1.5;
- };
- sheet.getCell(1, 1).formatter(new CustomNumberFormat());
-
- });
复制代码 |