hiprint.bundle.js 源码1740行代码,TableExcelHelper.getOrderdColumns方法修复
TableExcelHelper.getOrderdColumns = function (t) {
var maxRow = t.totalLayer;
var ret = [];
// 查找下层节点数据
var rowColStartMap = {};
var findLeafCol = function(nextRow, colspan){
var matchCols = [];
var start = rowColStartMap[nextRow]?rowColStartMap[nextRow]+1:0;
for(var i=start;i<t[nextRow].length;i++){
if(i - start >= colspan){
break;
}
if(t[nextRow][i].colspan > 1){
var dRet = findLeafCol(nextRow+1, t[nextRow][i].colspan);
dRet.forEach(function(dt){
matchCols.push(dt);
});
}else{
matchCols.push(t[nextRow][i]);
}
rowColStartMap[nextRow] = i;
}
return matchCols;
}
// 从顶部迭代
var startRow = 0;
t[startRow].forEach(function (t) {
if(maxRow == t.rowspan || 1 == t.colspan){
// 行到底层或者只占1列的数据
ret.push(t);
}else{
// 从next row取数据
var matchCols = findLeafCol(startRow+1, t.colspan);
matchCols.forEach(function(mt){
ret.push(mt);
});
}
});
return ret;
}