这个是数据源:
[{"销售部门":"晋陕","销售部代码":"6027","销售部":"陕西销售部(厨卫)","物料编码":"565102146098","物料名称":"立邦甄彩美缝剂(月光银)-10支","层次一":"厨卫","层次二":"填缝类","层次三":"立邦","层次四":"美缝剂","层次五":"立邦甄彩美缝剂","规格":"10支/箱","A价格(含税)":0,"去年月均":0,"10月实际数量":0,"10月实际金额(未税)":0,"11月预估数量":0,"12月预估数量":0,"1月预估数量":0,"11月预估金额(未税)":0,"12月预估金额(未税)":0,"1月预估金额(未税)":0},
{"销售部门":"晋陕","销售部代码":"6027","销售部":"陕西销售部(厨卫)","物料编码":"503400296002","物料名称":"靓彩易涂防水-华耐专供","层次一":"厨卫","层次二":"防水类","层次三":"乐可施","层次四":"通用防水","层次五":"乐可施经典通用防水","规格":"18KG","A价格(含税)":130,"去年月均":0,"10月实际数量":0,"10月实际金额(未税)":0,"11月预估数量":0,"12月预估数量":0,"1月预估数量":0,"11月预估金额(未税)":0,"12月预估金额(未税)":0,"1月预估金额(未税)":0}]
这个是代码:
var sheet = spread.getActiveSheet();
//绑定数据
sheet.autoGenerateColumns = true;
sheet.setDataSource(dataSource);
//冻结行和列
sheet.frozenColumnCount(5);
//设置列宽
sheet.setColumnWidth(0, 50);
sheet.setColumnWidth(1, 50);
sheet.setColumnWidth(2, 80);
sheet.setColumnWidth(3, 100);
sheet.setColumnWidth(4, 200);
sheet.setColumnWidth(5, 50);
sheet.setColumnWidth(6, 50);
sheet.setColumnWidth(7, 50);
sheet.setColumnWidth(8, 80);
sheet.setColumnWidth(9, 80);
sheet.setColumnWidth(10, 80);
sheet.setColumnWidth(11, 50);
sheet.setColumnWidth(12, 50);
sheet.setColumnWidth(13, 80);
sheet.setColumnWidth(14, 80);
sheet.setColumnWidth(15, 80);
sheet.setColumnWidth(16, 80);
sheet.setColumnWidth(17, 80);
sheet.setColumnWidth(18, 80);
sheet.setColumnWidth(19, 80);
sheet.setColumnWidth(20, 80);
//设置第三列格式为文本格式
sheet.getRange(0, dataSource.length, 3).formatter("@");
//开启单元格筛选
var cellrange = new GC.Spread.Sheets.Range(0, 0, dataSource.length, 12);
var hideRowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(cellrange);
sheet.rowFilter(hideRowFilter);
|