Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在kendo的Excel导出中隐藏数组中的第一个和最后一个对象?_Javascript_Ember.js_Kendo Grid - Fatal编程技术网

Javascript 如何在kendo的Excel导出中隐藏数组中的第一个和最后一个对象?

Javascript 如何在kendo的Excel导出中隐藏数组中的第一个和最后一个对象?,javascript,ember.js,kendo-grid,Javascript,Ember.js,Kendo Grid,我在我的余烬应用程序中使用剑道网格。我必须隐藏导出到Excel中的第一列和最后一列,并且必须修改Excel工作表中的列宽 如何从数组中隐藏对象 这是我的密码: excelExport : function(e) { e.preventDefault(); var str = e.sender.columns; var sheet = e.workbook.sheets[0]; var tindex = str.map(function(d) { retur

我在我的余烬应用程序中使用剑道网格。我必须隐藏导出到Excel中的第一列和最后一列,并且必须修改Excel工作表中的列宽

如何从数组中隐藏对象

这是我的密码:

excelExport : function(e) {
     e.preventDefault();
     var str = e.sender.columns;
     var sheet = e.workbook.sheets[0];
     var tindex = str.map(function(d) { return d['title']; }).indexOf('Action');
     var dindex = str.map(function(d) { return d['field']; }).indexOf('documentKey');

     sheet.columns.removeObject(dindex);sheet.columns.removeObject(tindex);

     var excelSheetColumns = sheet.columns.filter(function(d){
     console.log(">>>>>>"+d);    
     //d.removeObject(tindex);
     //d.removeObject(dindex);            

     d.width = 50;
     return d;
});

var workbook = new kendo.ooxml.Workbook({
    sheets:e.workbook.sheets
});

kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName:"export.xlsx"
});
试试这个:

var excelSheetColumns=sheet.columns.slice(2);
excelSheetColumns.forEach(function(col){col.width=50;});
var workbook = new kendo.ooxml.Workbook({
  sheets:excelSheetColumns
});

不工作..如何使用
excelSheetColumns
从Excel工作表中隐藏第一列。我已经更新了答案。这是可行的,但我需要从我的Excel工作表中删除第一列和最后一列。我总共有9个列。
var excelSheetColumns=sheet.columns.slice(1)删除第一个元素<代码>excelSheetColumns.pop()删除最后一个元素。看看不工作。。下载时,我得到一个空工作表