本帖最后由 344860032 于 2017-10-18 11:57 编辑
http://gcdn.gcpowertools.com.cn/ ... iewthread&tid=26905
参考这个例子,调用的时候报错,不知道什么原因
function NumberCellType() {
}
NumberCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
NumberCellType.prototype.createEditorElement = function (context) {
var editor = GC.Spread.Sheets.CellTypes.Text.prototype.createEditorElement.call(this, context);
var textarea = editor.firstChild;
textarea.onkeypress = function (event) {
return event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode == 46
}
textarea.onkeyup = function (event) {
this.value = this.value.replace(/[\u4e00-\u9fa5]/g, '').replace(/\D/g, '')
}
textarea.onpaste = function (event) {
var clipData = event.clipboardData;
return !clipData.getData('text').match(/\D/);
}
textarea.ondragenter = function (event) {
return false;
}
return editor;
};
sheet.setCellType(7, 8, new NumberCellType());
|
|