Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(pivot table show error): when column area have field and row area…
Browse files Browse the repository at this point in the history
… is null,pivot table show error
  • Loading branch information
DR-Univer committed Aug 1, 2020
1 parent 47fe25c commit 04bc51c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
24 changes: 23 additions & 1 deletion src/controllers/pivotTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ const pivotTable = {
}

let datacoltitle_index = datacoltitle;
datacoltitle = luckysheetArray.transpose(datacoltitle);
datacoltitle = luckysheetArray.transpose(datacoltitle, false);

let valuenslen = values.length == 0 ? 0 : 1;
let rowLen = (datacoltitle.length == 0 ? valuenslen : datacoltitle.length) + (datarowtitle.length == 0 ? valuenslen : datarowtitle.length), colLen = (datacoltitle.length == 0 ? valuenslen : datacoltitle[0].length) + (datarowtitle.length == 0 ? valuenslen : datarowtitle[0].length);
Expand Down Expand Up @@ -3015,6 +3015,28 @@ const pivotTable = {
retdata[0][0] = values[0].fullname;
retdata.splice(column.length, 1);
}
else if(values.length == 1 && column.length > 0){
// 0: (6) ["English", "foreign language", "mathematics", "science", "Sum", undefined]
// 1: (6) ["CountA:score", "CountA:score", "CountA:score", "CountA:score", "CountA:score", undefined]
// 2: (6) [3, 3, 3, 3, 12, ""]
//The above format does not meet viewing habits,Process retdata into the correct format
let titleRow = retdata.splice(column.length, 1);
let newRetdata = [];
for(let r=0;r<retdata.length;r++){
let row = [];
if(r==retdata.length-1){
row.push(titleRow[0][0]);
}
else{
row.push("");
}
for(let c=0;c<retdata[r].length-1;c++){
row.push(retdata[r][c]);
}
newRetdata.push(row);
}
retdata = newRetdata;
}

_this.pivotDatas = retdata;

Expand Down
9 changes: 7 additions & 2 deletions src/global/array.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getcellvalue } from './getdata';

const luckysheetArray = {
transpose: function (getdata) {
transpose: function (getdata, useGetcellValue=true) {
let arr = [];
if (getdata.length == 0) {
return [];
Expand All @@ -16,7 +16,12 @@ const luckysheetArray = {
for (let r = 0; r < getdata.length; r++) {
let value = "";
if (getdata[r] != null && getdata[r][c] != null) {
value = getcellvalue(r, c, getdata);
if(useGetcellValue){
value = getcellvalue(r, c, getdata);
}
else{
value = getdata[r][c];
}
}
a.push(value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ export default {
titleSelectionDataRange:"Select range",
titleDataRange:"Data range",

valueSum:"Sum",
valueSum:"SUM",

valueStatisticsSUM:"Sum",
valueStatisticsCOUNT:"Count",
Expand Down

0 comments on commit 04bc51c

Please sign in to comment.