我有一个表格,一个单元格为了设置不可编辑状态,设置了单元格锁定状态,然后整个工作表设置了保护状态,然后我新增了一行,复制了样式过来,但是这个不可编辑状态没有复制过来,我新增一行的代码是这么写的。
insertTable() {
var sheet = spread.getActiveSheet();
if (sheet) {
sheet.suspendEvent();
let table=sheet.tables.all()[0];
let allSheets=spread.toJSON().sheets;
let name = sheet.name();
let activeSheet=allSheets[name];
let col=null;
let copyRow=null;
if(activeSheet.tables[0].useFooterDropDownList){//是否有汇总行
sheet.addRows(sheet.getRowCount()-1, 1);
// table.insertRows(sheet.getRowCount() - 4, 1, true);
let dataRange=table.dataRange();
let row=dataRange.rowCount;
col=dataRange.colCount;
copyRow=row+dataRange.row
sheet.copyTo(copyRow-2, 0, copyRow-1, 0, 1, col, GC.Spread.Sheets.CopyToOptions.style|GC.Spread.Sheets.CopyToOptions.formula|GC.Spread.Sheets.CopyToOptions.tag);
sheet.copyTo(copyRow-2, 0, copyRow-1, 0, 1,GC.Spread.Sheets.CopyToOptions.all)
var rh = sheet.getRowHeight(copyRow-2, GC.Spread.Sheets.SheetArea.viewport);
var rowCount = sheet.getRowCount();
// 挂起事件响应
sheet.setRowHeight(copyRow-2, rh, GC.Spread.Sheets.SheetArea.viewport);
for (let i = 0; i < col; i++) {
let tag = sheet.getTag(copyRow-2, i);
tag=this.getCellTag(tag)
if (tag.comboxTree) {
let cell = sheet.getCellType(copyRow-2, i)
var cellType = new ComboTreeCellType({onlyReturnLeaf:tag.comboxTree.onlyReturnLeaf});
cellType.items(cell._items);
sheet.setCellType(copyRow-1, i, cellType);
}
}
}else{
sheet.addRows(sheet.getRowCount(), 1);
table.insertRows(sheet.getRowCount() - 3, 1, true);
let dataRange=table.dataRange();
let row=dataRange.rowCount;
col=dataRange.colCount;
copyRow=row+dataRange.row
sheet.copyTo(row-1, 0, row, 0, 1, col, GC.Spread.Sheets.CopyToOptions.style|GC.Spread.Sheets.CopyToOptions.formula|GC.Spread.Sheets.CopyToOptions.tag);
sheet.copyTo(copyRow-2, 0, copyRow-1, 0, 1,GC.Spread.Sheets.CopyToOptions.all)
var rh = sheet.getRowHeight(row-1, GC.Spread.Sheets.SheetArea.viewport);
var rowCount = sheet.getRowCount();
// 挂起事件响应
sheet.setRowHeight(row, rh, GC.Spread.Sheets.SheetArea.viewport);
//新增行的下拉树数据及格式复制
for (let i = 0; i < col; i++) {
let tag = sheet.getTag(row-1, i);
tag=this.getCellTag(tag)
if (tag.comboxTree) {
let cell = sheet.getCellType(1, i)
var cellType = new ComboTreeCellType({onlyReturnLeaf:tag.comboxTree.onlyReturnLeaf});
cellType.items(cell._items);
sheet.setCellType(row, i, cellType);
}
}
}
// 恢复事件响应
sheet.resumeEvent();
}
},
|