您好,
参考下方代码:
- sheet.bind(GC.Spread.Sheets.Events.FloatingObjectChanged, function (e, info) {
- console.log(sheet.floatingObjects.all()[0].x());
- console.log(sheet.floatingObjects.all()[0].y());
- var x = sheet.floatingObjects.all()[0].x();
- var y = sheet.floatingObjects.all()[0].y();
- var rangeX = sheet.getColumnWidth(0)*10;
- var rangeY = sheet.getRowHeight(0)*10;
- // 限制单元格区域为10行、10列
- if(x > rangeX) {
- sheet.floatingObjects.all()[0].x(rangeX);
- } else if(y > rangeY ) {
- sheet.floatingObjects.all()[0].y(rangeY);
- }
- });
复制代码 |