本帖最后由 lynn512 于 2020-10-19 13:43 编辑
分析您的代码,传参时参数有误,从图中来看,你表格数据共5行,但是传入参数为6。将其改为5即可实现排序。
- sortcommand() {
- // let columnCount = this.activeSheet.getColumnCount()
- // this.activeSheet.sortRange(1, 0, 6, columnCount, true, [
- // { index: 2, ascending: false}, //降序
- // ]);
- var table = this.activeSheet.tables.all()[0];
- var colCount = table.dataRange().colCount;
- this.activeSheet.sortRange(1, 0, 5, colCount, true, [
- { index: 2, ascending: false} //降序
- ]);
- },
复制代码
|