您好,调整了下您的代码逻辑,修改后如下:
- var GCsheets = GC.Spread.Sheets;
- let data = {
- name: 'Jones', region: 'East',
- sales: [
- {orderDate: '1/6/2013', item: 'Pencil', units: 95, cost: 1.99, isDelivered: '是'},
- {orderDate: '4/1/2013', item: 'Binder', units: 60, cost: 4.99, isDelivered: '否'},
- {orderDate: '6/8/2013', item: 'Pen Set', units: 16, cost: 15.99, isDelivered: ''}
- ]
- };
- let convert = function (item) {
- return item['cost'] + "tableColumn5.cellType(combo).value('是');设置不起作用";
- }
- let table = sheet.tables.add('tableSales', 0, 0, 5, 5);
- table.style(GCsheets.Tables.TableThemes["medium4"]);
- const combo = new GCsheets.CellTypes.ComboBox();
- combo.items([{text: '是', value: 1},{text: '否', value: 0}])
- let tableColumn1 = new GCsheets.Tables.TableColumn(1, "orderDate", "Order Date", "yyyy-mm-dd");
- let tableColumn2 = new GCsheets.Tables.TableColumn(2, "item", "Item");
- let tableColumn3 = new GCsheets.Tables.TableColumn(3, "units", "Units");
- let tableColumn4 = new GCsheets.Tables.TableColumn(4, "cost", "Cost", null, null, convert);
- let tableColumn5 = new GCsheets.Tables.TableColumn(5,"isDelivered", "选择", null, combo);
- // tableColumn5.cellType(combo).value('是');
- //tableColumn5.name('选择');
- table.autoGenerateColumns(false);
- table.bind([tableColumn1, tableColumn2, tableColumn3, tableColumn4, tableColumn5], 'sales', data);
- sheet.setColumnWidth(0, 120);
- sheet.setColumnWidth(1, 120);
- sheet.setColumnWidth(2, 120);
- sheet.setColumnWidth(3, 120);
- sheet.setColumnWidth(4, 120);
- spread.resumePaint();
复制代码
测试结果:
|