您好,可以参考以下代码来实现:
- sheet.bind(GC.Spread.Sheets.Events.CellChanged, function (e, info) {
- if (!info.isUndo) {
- let row = info.row;
- let col = info.col;
- if (
- sheet.getStyle(row, col).cellButtons[0].command === "openDateTimePicker"
- ) {
- let newDate = info.newValue;
- console.log(newDate);
- if (newDate < Date.now()) {
- let cell = sheet.getCell(row, col);
- sheet.suspendEvent();
- cell.value(info.oldValue);
- sheet.resumeEvent();
- alert("非法修改,日期不得早于当前时间!");
- }
- }
- }
- });
复制代码 |