上面的回答中上传了附件,您可以打开看下。
另附上完整代码:
- $(function () {
- //数据源
- var dataSource = '[{"销售部门":"晋陕","销售部代码":"6027","销售部":"陕西销售部(厨卫)","物料编码":"565102146098","物料名称":"立邦甄彩美缝剂(月光银)-10支","层次一":"厨卫","层次二":"填缝类","层次三":"立邦","层次四":"美缝剂","层次五":"立邦甄彩美缝剂","规格":"10支/箱","A价格(含税)":1,"去年月均":0,"10月实际数量":0,"10月实际金额(未税)":0,"11月预估数量":2,"12月预估数量":0,"1月预估数量":0,"11月预估金额(未税)":0,"12月预估金额(未税)":0,"1月预估金额(未税)":0},{ "销售部门": "晋陕", "销售部代码": "6027", "销售部": "陕西销售部(厨卫)", "物料编码": "503400296002", "物料名称": "靓彩易涂防水-华耐专供", "层次一": "厨卫", "层次二": "防水类", "层次三": "乐可施", "层次四": "通用防水", "层次五": "乐可施经典通用防水", "规格": "18KG", "A价格(含税)": 130, "去年月均": 0, "10月实际数量": 0, "10月实际金额(未税)": 0, "11月预估数量": 2, "12月预估数量": 2, "1月预估数量": 2, "11月预估金额(未税)": 0, "12月预估金额(未税)": 0, "1月预估金额(未税)": 0 }]';
- dataSource = JSON.parse(dataSource);
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- var sheet = spread.getActiveSheet();
- sheet.setColumnCount(30); // 初始化默认列数 < 数据源,所以先设置好列数,再执行下面这句代码
- //创建表格
- var table = sheet.tables.addFromDataSource('table1', 0, 0, dataSource);
-
- table.setColumnDataFormula(18, "=[@A价格(含税)]*[@11月预估数量]");
- table.setColumnDataFormula(19, "=[@A价格(含税)]*[@12月预估数量]");
- table.setColumnDataFormula(20, "=[@A价格(含税)]*[@1月预估数量]");
- sheet.recalcAll()
- });
复制代码
|