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

set field number format

parent 50369b43
......@@ -3439,6 +3439,18 @@ CT_DateTime.prototype.toXml = function(writer, name) {
}
writer.WriteXmlNodeEnd(name);
};
CT_DateTime.prototype.getCellValue = function (subtotal) {
var res = new AscCommonExcel.CCellValue();
var v = new Date(this.v).getExcelDateWithTime();
if (subtotal) {
res.text = v + subtotal;
res.type = AscCommon.CellValueType.String;
} else {
res.number = v;
res.type = AscCommon.CellValueType.Number;
}
return res;
};
function CT_Error() {
//Attributes
this.v = null;
......@@ -3850,6 +3862,17 @@ CT_Number.prototype.toXml = function(writer, name) {
}
writer.WriteXmlNodeEnd(name);
};
CT_Number.prototype.getCellValue = function (subtotal) {
var res = new AscCommonExcel.CCellValue();
if (subtotal) {
res.text = this.v + subtotal;
res.type = AscCommon.CellValueType.String;
} else {
res.number = this.v;
res.type = AscCommon.CellValueType.Number;
}
return res;
};
function CT_String() {
//Attributes
this.v = null;
......@@ -3990,6 +4013,12 @@ CT_String.prototype.toXml = function(writer, name) {
}
writer.WriteXmlNodeEnd(name);
};
CT_String.prototype.getCellValue = function (subtotal) {
var res = new AscCommonExcel.CCellValue();
res.text = this.v + (subtotal ? subtotal : '');
res.type = AscCommon.CellValueType.String;
return res;
};
function CT_Index() {
//Attributes
this.v = null;
......
......@@ -4924,7 +4924,8 @@
}
};
Worksheet.prototype._updatePivotTable = function (pivotTable, cleanRanges) {
var pos, cells, index, i, j, v, r, c1, r1, field, indexField, cacheIndex, sharedItem, item, items, setName;
var pos, cells, index, i, j, v, r, c1, r1, field, indexField, cacheIndex, sharedItem, item, items, setName,
oCellValue;
for (i = 0; i < cleanRanges.length; ++i) {
cleanRanges[i].cleanAll();
}
......@@ -4964,21 +4965,25 @@
r = item.getR();
for (j = 0; j < item.x.length; ++j) {
if (AscCommonExcel.c_oAscItemType.Grand === item.t) {
v = 'Grand Total';
field = null;
oCellValue = new AscCommonExcel.CCellValue();
oCellValue.text = 'Grand Total';
oCellValue.type = AscCommon.CellValueType.String;
} else {
indexField = colFields[r + j].asc_getIndex();
cacheIndex = pivotFields[indexField].getItem(item.x[j].getV());
field = pivotFields[indexField];
cacheIndex = field.getItem(item.x[j].getV());
sharedItem = cacheFields[indexField].getSharedItem(cacheIndex.x);
v = sharedItem.v;
}
if (AscCommonExcel.c_oAscItemType.Default === item.t) {
// ToDo add other names by type
v += ' Total';
oCellValue = sharedItem.getCellValue(
AscCommonExcel.c_oAscItemType.Default === item.t ? ' Total' : null);
}
cells = this.getRange4(r1 + r + j, c1 + i);
cells.setValue(v);
if (field && null !== field.numFmtId) {
cells.setNum(new AscCommonExcel.Num({id: field.numFmtId}));
}
cells.setValueData(new AscCommonExcel.UndoRedoData_CellValueData(null, oCellValue));
}
}
}
......@@ -5016,16 +5021,23 @@
r = item.getR();
for (j = 0; j < item.x.length; ++j) {
if (AscCommonExcel.c_oAscItemType.Grand === item.t) {
v = 'Grand Total';
field = null;
oCellValue = new AscCommonExcel.CCellValue();
oCellValue.text = 'Grand Total';
oCellValue.type = AscCommon.CellValueType.String;
} else {
indexField = rowFields[r].asc_getIndex();
cacheIndex = pivotFields[indexField].getItem(item.x[j].getV());
field = pivotFields[indexField];
cacheIndex = field.getItem(item.x[j].getV());
sharedItem = cacheFields[indexField].getSharedItem(cacheIndex.x);
v = sharedItem.v;
oCellValue = sharedItem.getCellValue();
}
cells = this.getRange4(r1 + i, rowFieldsPos[item.getR()]);
cells.setValue(v);
if (field && null !== field.numFmtId) {
cells.setNum(new AscCommonExcel.Num({id: field.numFmtId}));
}
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