//公式部分
//原材料明细的公式
setFormulaFun: function (sheet, start, end) {
for (var i = 0; i < sheet.getRowCount(); i++) {
for (var j = 0; j < sheet.getColumnCount(); j++) {
if (i >= start && i <= end - 1) {
if (j == 17) {
sheet.setFormula(i, j, 'IFERROR(RC[-1]/RC[-2]," ")', GC.Spread.Sheets.SheetArea.viewport);
} else if (j == 19) {
sheet.setFormula(i, j, 'IFERROR(IF(RC[-16]*RC[-1]*(RC[-4]-RC[-3])=0," ",RC[-16]*RC[-1]*(RC[-4]-RC[-3]))," ")', GC.Spread.Sheets.SheetArea.viewport);
} else if (j == 20) {
sheet.setFormula(i, j, 'IFERROR((RC[-17]*(RC[-9]*RC[-5]-RC[-1]))," ")', GC.Spread.Sheets.SheetArea.viewport)
}
} else if (i == end) {
if (j == 15 || j == 16 || j == 17 || j == 19 || j == 20) {
sheet.setFormula(i, j, 'IFERROR(SUM(R[-7]C:R[-1]C)," ")', GC.Spread.Sheets.SheetArea.viewport);
}
}
}
}
},
//初始化sheet页
initRawMaterialSheet: function (spread, data) {
var me = this;
let sheet = spread.getSheetFromName('原材料明细')
spread.suspendPaint();
let CbdRawMaterialIndex = 6;
sheet.options.isProtected = false;
sheet.addRows(CbdRawMaterialIndex, data.CbdRawMaterial.length-1);
for (i = 1; i < data.CbdRawMaterial.length; i++) {
sheet.copyTo(
CbdRawMaterialIndex,
-1,
CbdRawMaterialIndex + i,
-1,
1,
sheet.getColumnCount(),
GC.Spread.Sheets.CopyToOptions.all
);
}
sheet.options.isProtected = true;
// //给整个表设置绑定数据,包括table
let dataSource = new GC.Spread.Sheets.Bindings.CellBindingSource(data);
sheet.setDataSource(dataSource);
//给单元格设置公式
this.setFormulaFun(sheet, me.tableBeginRowIndex, me.tableBeginRowIndex + data.CbdRawMaterial.length)
spread.resumePaint();
},
|
|