可以参考附件中的demo来实现您想要的结果:- var sheet = spread.getActiveSheet();
- sheet.setValue(0, 0, 12);
- sheet.setFormula(0, 1, '=A1*1')
- var getPrecedents = sheet.getPrecedents(0, 1);
- var row = [],
- col = [],
- value = [];
- for (var i = 0; i < getPrecedents.length; i++) {
- row.push(getPrecedents[i].row);
- col.push(getPrecedents[i].col);
- value.push(sheet.getValue(row, col));
- }
- sheet.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
- var newValue = info.newValue;
- setTimeout(function () {
- for (var i = 0; i < row.length; i++) {
- if (info.row === row[i] && info.col === col[i]) {
- if (newValue !== value[i]) {
- const cellStyle = new GC.Spread.Sheets.Style();
- cellStyle.backColor = 'red';
- sheet.setStyle(info.row, info.col, cellStyle);
- }
- }
- }
- }, 0)
- });
复制代码 最后实现效果是:
其中可以参考这篇帖子:
https://gcdn.grapecity.com.cn/fo ... hread&tid=81568
|