spread解决div/0错误

2022/10/16 spread.jsexcel

Spread JS可以用自定义单元格类型的方法来实现不显示DIV/0

    function ShowValueCellType() {
    }
    ShowValueCellType.prototype = new spreadNS.CellTypes.Text();
    ShowValueCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
        if (value && value._error === "#DIV/0!") {
            // 在这里改变值
            value = 0;
        }
        spreadNS.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options]);
    };
    // 为整列添加自定义单元格类型
    sheet.setCellType(-1, 2, new ShowValueCellType());
1
2
3
4
5
6
7
8
9
10
11
12
最后更新时间: 2023/1/12 15:59:09