这是调用的代码 我只想修改符合条件的单元格和单元格区域,这样执行以后,全都不能编辑了 ,麻烦看一下
- var spread = designer.wrapper.spread;
- var sheetCount = spread.getSheetCount();
- var sheet;
- for (var i = 0; i < sheetCount; i++) {
- sheet = spread.getSheet(i);
- sheet.options.isProtected = true;
- // var style = sheet.getDefaultStyle();
- // style.locked = false;
- var rowCount = sheet.getRowCount();
- var columnCount = sheet.getColumnCount();
- for (var row = 0; row < rowCount; row++) {
- for (var col = 0; col < columnCount; col++) {
- var bindingPathArray = [];
- var bindingPathKey;
- bindingPathKey = sheet.getBindingPath(row, col);
- if (bindingPathKey) {
- sheet.getCell(row, col ).locked(true);
- }
- }
- }
- var tables = sheet.tables.all();
- if(tables){
- for (var j = 0; j < tables.length; j++){
- if(tables[j].bindingPath()){
- var range = tables[j].dataRange();
- var spans =sheet.getSpans(range);
- sheet.getRange(range).locked(true);
- }
- }
- }
- sheet.options.isProtected = false;
- }
复制代码 |