Commit a0035c7f authored by Alexander.Trofimov's avatar Alexander.Trofimov

support other types of subtotals it fields

parent 50bab978
...@@ -4945,4 +4945,8 @@ ...@@ -4945,4 +4945,8 @@
return this.value = truncHelper(arg0.getValue(), arg1.getValue()); return this.value = truncHelper(arg0.getValue(), arg1.getValue());
}; };
//----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].cSUBTOTAL = cSUBTOTAL;
})(window); })(window);
...@@ -21,34 +21,34 @@ var c_oAscFieldSortType = { ...@@ -21,34 +21,34 @@ var c_oAscFieldSortType = {
Descending: 2 Descending: 2
}; };
var c_oAscItemType = { var c_oAscItemType = {
Data: 0, Default: 0,
Default: 1, Avg: 1,
Sum: 2, Count: 2,
CountA: 3, CountA: 3,
Avg: 4, Max: 4,
Max: 5, Min: 5,
Min: 6, Product: 6,
Product: 7, StdDev: 7,
Count: 8, StdDevP: 8,
StdDev: 9, Sum: 9,
StdDevP: 10, Var: 10,
Var: 11, VarP: 11,
VarP: 12, Data: 12,
Grand: 13, Grand: 13,
Blank: 14 Blank: 14
}; };
var c_oAscDataConsolidateFunction = { var c_oAscDataConsolidateFunction = {
Average: 0, Average: 1,
Count: 1, Count: 2,
CountNums: 2, CountNums: 3,
Max: 3, Max: 4,
Min: 4, Min: 5,
Product: 5, Product: 6,
StdDev: 6, StdDev: 7,
StdDevp: 7, StdDevp: 8,
Sum: 8, Sum: 9,
Var: 9, Var: 10,
Varp: 10 Varp: 11
}; };
var c_oAscShowDataAs = { var c_oAscShowDataAs = {
Normal: 0, Normal: 0,
...@@ -426,36 +426,36 @@ function ToXml_ST_ItemType(val) { ...@@ -426,36 +426,36 @@ function ToXml_ST_ItemType(val) {
function ToName_ST_ItemType(val) { function ToName_ST_ItemType(val) {
var res = ' '; var res = ' ';
if (c_oAscItemType.Data === val) { if (c_oAscItemType.Default === val) {
res += "data";
} else if (c_oAscItemType.Default === val) {
res += 'Total'; res += 'Total';
} else if (c_oAscItemType.Sum === val) {
res = 'Sum';
} else if (c_oAscItemType.CountA === val) {
res = 'Count';
} else if (c_oAscItemType.Avg === val) { } else if (c_oAscItemType.Avg === val) {
res = 'Average'; res += 'Average';
} else if (c_oAscItemType.Count === val) {
res += 'Count';
} else if (c_oAscItemType.CountA === val) {
res += 'Count';
} else if (c_oAscItemType.Max === val) { } else if (c_oAscItemType.Max === val) {
res = 'Max'; res += 'Max';
} else if (c_oAscItemType.Min === val) { } else if (c_oAscItemType.Min === val) {
res = 'Min'; res += 'Min';
} else if (c_oAscItemType.Product === val) { } else if (c_oAscItemType.Product === val) {
res = 'Product'; res += 'Product';
} else if (c_oAscItemType.Count === val) {
res = 'Count';
} else if (c_oAscItemType.StdDev === val) { } else if (c_oAscItemType.StdDev === val) {
res = 'StdDev'; res += 'StdDev';
} else if (c_oAscItemType.StdDevP === val) { } else if (c_oAscItemType.StdDevP === val) {
res = 'StdDevp'; res += 'StdDevp';
} else if (c_oAscItemType.Sum === val) {
res += 'Sum';
} else if (c_oAscItemType.Var === val) { } else if (c_oAscItemType.Var === val) {
res = 'Var'; res += 'Var';
} else if (c_oAscItemType.VarP === val) { } else if (c_oAscItemType.VarP === val) {
res = 'Varp'; res += 'Varp';
} else if (c_oAscItemType.Data === val) {
res += 'Data';
} else if (c_oAscItemType.Grand === val) { } else if (c_oAscItemType.Grand === val) {
res += 'Total'; res += 'Total';
} else if (c_oAscItemType.Blank === val) { } else if (c_oAscItemType.Blank === val) {
res = "blank"; res += 'Blank';
} }
return res; return res;
} }
...@@ -2750,9 +2750,12 @@ CT_pivotTableDefinition.prototype.getValues = function (records, index, value) { ...@@ -2750,9 +2750,12 @@ CT_pivotTableDefinition.prototype.getValues = function (records, index, value) {
} }
return res; return res;
}; };
CT_pivotTableDefinition.prototype.getValue = function (records, index) { CT_pivotTableDefinition.prototype.getValue = function (records, index, subtotal) {
var cacheFields = this.asc_getCacheFields(); var cacheFields = this.asc_getCacheFields();
var res = 0; if (c_oAscItemType.Default === subtotal || c_oAscItemType.Data === subtotal || c_oAscItemType.Blank === subtotal) {
subtotal = c_oAscItemType.Sum;
}
var arg = [new AscCommonExcel.cNumber(subtotal)];
var elem; var elem;
for (var i = 0; i < records.length; ++i) { for (var i = 0; i < records.length; ++i) {
elem = records[i][index]; elem = records[i][index];
...@@ -2760,10 +2763,13 @@ CT_pivotTableDefinition.prototype.getValue = function (records, index) { ...@@ -2760,10 +2763,13 @@ CT_pivotTableDefinition.prototype.getValue = function (records, index) {
elem = cacheFields[index].getSharedItem(elem.v); elem = cacheFields[index].getSharedItem(elem.v);
} }
if (elem instanceof CT_Number) { if (elem instanceof CT_Number) {
res += elem.v; arg.push(new AscCommonExcel.cNumber(elem.v));
} }
} }
return res;
var f = new AscCommonExcel.cSUBTOTAL();
return f.Calculate(arg);
}; };
CT_pivotTableDefinition.prototype.asc_getName = function () { CT_pivotTableDefinition.prototype.asc_getName = function () {
return this.name; return this.name;
......
...@@ -5096,7 +5096,9 @@ ...@@ -5096,7 +5096,9 @@
if (0 !== cacheRecord.length) { if (0 !== cacheRecord.length) {
cells = this.getRange4(r1 + i, rowFieldsPos[r] + 1 + j); cells = this.getRange4(r1 + i, rowFieldsPos[r] + 1 + j);
oCellValue = new AscCommonExcel.CCellValue(); oCellValue = new AscCommonExcel.CCellValue();
oCellValue.number = pivotTable.getValue(cacheRecord, dataFields[0].asc_getIndex()); oCellValue.number = pivotTable.getValue(cacheRecord, dataFields[0].asc_getIndex(),
(null !== item.t && c_oAscItemType.Grand !== item.t) ? item.t :
dataFields[0].asc_getSubtotal());
oCellValue.type = AscCommon.CellValueType.Number; oCellValue.type = AscCommon.CellValueType.Number;
cells.setValueData(new AscCommonExcel.UndoRedoData_CellValueData(null, oCellValue)); cells.setValueData(new AscCommonExcel.UndoRedoData_CellValueData(null, oCellValue));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment