Skip to content

Commit

Permalink
Release 18.2.2-pre-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
BingoRUS committed Oct 26, 2018
1 parent d5600f1 commit ce70a15
Show file tree
Hide file tree
Showing 31 changed files with 897 additions and 667 deletions.
73 changes: 49 additions & 24 deletions js/client_exporter/excel_creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var Class = require("../core/class"),
fileSaver = require("./file_saver"),
excelFormatConverter = require("./excel_format_converter"),
XlsxFile = require("./xlsx/xlsx_file"),
isDefined = typeUtils.isDefined,
XML_TAG = "<?xml version=\"1.0\" encoding=\"utf-8\"?>",
GROUP_SHEET_PR_XML = "<sheetPr><outlinePr summaryBelow=\"0\"/></sheetPr>",
SINGLE_SHEET_PR_XML = "<sheetPr/>",
Expand Down Expand Up @@ -174,28 +175,52 @@ var ExcelCreator = Class.inherit({
},

_callCustomizeExcelCell: function({ dataProvider, value, dataType, style, sourceData }) {
const style_args = XlsxFile.copyCellFormat(style);
const numberFormat = style_args.numberFormat;
delete style_args.numberFormat;
const styleCopy = XlsxFile.copyCellFormat(style);

const args = {
xlsxCell: {
style: style_args,
value: value,
dataType: dataType,
numberFormat: numberFormat,
},
cellSourceData: sourceData
value: value,
numberFormat: styleCopy.numberFormat,
clearStyle: function() {
this.horizontalAlignment = null;
this.verticalAlignment = null;
this.wrapTextEnabled = null;
this.font = null;
this.numberFormat = null;
}
};

dataProvider.customizeExcelCell(args);
if(isDefined(styleCopy)) {
if(isDefined(styleCopy.alignment)) {
args.horizontalAlignment = styleCopy.alignment.horizontal;
args.verticalAlignment = styleCopy.alignment.vertical;
args.wrapTextEnabled = styleCopy.alignment.wrapText;
}
args.backgroundColor = styleCopy.backgroundColor;
args.fillPatternType = styleCopy.fillPatternType;
args.fillPatternColor = styleCopy.fillPatternColor;
args.font = styleCopy.font;
}

dataProvider.customizeExcelCell(args, sourceData);

let newStyle = styleCopy || {};

newStyle.font = args.font;

newStyle.alignment = newStyle.alignment || {};
newStyle.alignment.horizontal = args.horizontalAlignment;
newStyle.alignment.vertical = args.verticalAlignment;
newStyle.alignment.wrapText = args.wrapTextEnabled;

newStyle.backgroundColor = args.backgroundColor;
newStyle.fillPatternType = args.fillPatternType;
newStyle.fillPatternColor = args.fillPatternColor;

const newStyle = args.xlsxCell.style || {};
newStyle.numberFormat = args.xlsxCell.numberFormat;
newStyle.numberFormat = args.numberFormat;

return {
value: args.xlsxCell.value,
dataType: args.xlsxCell.dataType,
value: args.value,
dataType: dataType,
style: newStyle,
};
},
Expand All @@ -221,37 +246,37 @@ var ExcelCreator = Class.inherit({
let cellStyleId = this._styleIdToRegisteredStyleIdMap[dataProvider.getStyleId(rowIndex, cellIndex)];
if(dataProvider.hasCustomizeExcelCell && dataProvider.hasCustomizeExcelCell()) {
const value = cellData.sourceValue || cellData.value;
const modifiedXlsxCell = this._callCustomizeExcelCell({
const modifiedExcelCell = this._callCustomizeExcelCell({
dataProvider: dataProvider,
value: value,
dataType: cellData.type,
style: that._styleArray[cellStyleId],
sourceData: cellData.cellSourceData,
});

cellData.type = modifiedXlsxCell.dataType;
if(modifiedXlsxCell.value !== value) {
cellData.type = modifiedExcelCell.dataType;
if(modifiedExcelCell.value !== value) {
// 18.18.11 ST_CellType (Cell Type)
switch(cellData.type) {
case 's':
cellData.value = this._appendString(modifiedXlsxCell.value);
cellData.value = this._appendString(modifiedExcelCell.value);
break;
case 'd':
cellData.value = modifiedXlsxCell.value;
cellData.value = modifiedExcelCell.value;
break;
case 'n':
let newValue = modifiedXlsxCell.value;
let newValue = modifiedExcelCell.value;
const excelDateValue = this._tryGetExcelDateValue(newValue);
if(typeUtils.isDefined(excelDateValue)) {
newValue = excelDateValue;
}
cellData.value = newValue;
break;
default:
cellData.value = modifiedXlsxCell.value;
cellData.value = modifiedExcelCell.value;
}
}
cellStyleId = this._xlsxFile.registerCellFormat(modifiedXlsxCell.style);
cellStyleId = this._xlsxFile.registerCellFormat(modifiedExcelCell.style);
}
cellsArray.push({
style: cellStyleId,
Expand Down Expand Up @@ -301,7 +326,7 @@ var ExcelCreator = Class.inherit({
numberFormat,
alignment: {
vertical: "top",
wrapText: Number(!!style.wrapText),
wrapText: !!style.wrapText,
horizontal: style.alignment || "left"
}
});
Expand Down
30 changes: 20 additions & 10 deletions js/client_exporter/xlsx/xlsx_color_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ const xlsxColorHelper = {
tryCreateTag: function(sourceObj) {
let result = null;
if(isDefined(sourceObj)) {
result = {
rgb: sourceObj.rgb,
theme: sourceObj.theme,
};
if(typeof sourceObj === 'string') {
result = {
rgb: sourceObj
};
} else {
result = {
rgb: sourceObj.rgb,
theme: sourceObj.theme,
};
}
if(xlsxColorHelper.isEmpty(result)) {
result = null;
}
Expand All @@ -19,12 +25,16 @@ const xlsxColorHelper = {
copy: function(source) {
let result = null;
if(isDefined(source)) {
result = {};
if(source.rgb !== undefined) {
result.rgb = source.rgb;
}
if(source.theme !== undefined) {
result.theme = source.theme;
if(typeof source === 'string') {
result = source;
} else {
result = {};
if(source.rgb !== undefined) {
result.rgb = source.rgb;
}
if(source.theme !== undefined) {
result.theme = source.theme;
}
}
}
return result;
Expand Down
114 changes: 16 additions & 98 deletions js/client_exporter/xlsx/xlsx_elements.js
Original file line number Diff line number Diff line change
@@ -1,135 +1,53 @@
/**
* @name XlsxCell
* @name ExcelFont
* @type object
* @hidden
*/
/**
* @name XlsxCell.value
* @type string|number|date|boolean
*/
/**
* @name XlsxCell.dataType
* @type Enums.XlsxCellDataType
*/

/**
* @name XlsxCell.numberFormat
* @type string
*/

/**
* @name XlsxCell.style
* @type object
*/

/**
* @name XlsxCell.style.alignment
* @type object
*/
/**
* @name XlsxCell.style.alignment.horizontal
* @type Enums.XlsxHorizontalAlignment
*/
/**
* @name XlsxCell.style.alignment.vertical
* @type Enums.XlsxVerticalAlignment
*/
/**
* @name XlsxCell.style.alignment.wrapText
* @type boolean
*/

/**
* @name XlsxCell.style.backgroundColor
* @type string
*/
/**
* @name XlsxCell.style.patternStyle
* @type Enums.XlsxPatternStyle
*/
/**
* @name XlsxCell.style.patternColor
* @type string
*/

/**
* @name XlsxCell.style.font
* @type object
*/
/**
* @name XlsxCell.style.font.size
* @name ExcelFont.size
* @type number
*/
/**
* @name XlsxCell.style.font.name
* @name ExcelFont.name
* @type string
*/
/**
* @name XlsxCell.style.font.bold
* @name ExcelFont.bold
* @type boolean
*/
/**
* @name XlsxCell.style.font.italic
* @name ExcelFont.italic
* @type boolean
*/
/**
* @name XlsxCell.style.font.underline
* @type Enums.XlsxUnderlineType
* @name ExcelFont.underline
* @type Enums.ExcelFontUnderlineType
*/
/**
* @name XlsxCell.style.font.color
* @type XlsxColor
*/

/**
* @name XlsxColor
* @type object
* @hidden
*/
/**
* @name XlsxColor.rgb
* @name ExcelFont.color
* @type string
*/

/**
* @name XlsxGridCell
* @name ExcelDataGridCell
* @type object
* @hidden
*/
/**
* @name XlsxGridCell.rowType
* @name ExcelDataGridCell.rowType
* @type string
*/
/**
* @name XlsxGridCell.column
* @type dxDataGridColumn
* @name ExcelDataGridCell.data
* @type object
*/
/**
* @name XlsxGridCell.value
* @name ExcelDataGridCell.key
* @type any
*/
/**
* @name XlsxGridCell.displayValue
* @type string
*/
/**
* @name XlsxGridCell.text
* @type string
*/

/**
* @name XlsxGridCell.row
* @type object
*/
/**
* @name XlsxGridCell.row.data
* @type object
* @name ExcelDataGridCell.column
* @type dxDataGridColumn
*/
/**
* @name XlsxGridCell.row.key
* @name ExcelDataGridCell.value
* @type any
*/
/**
* @name XlsxGridCell.row.rowType
* @type string
*/
18 changes: 9 additions & 9 deletions js/client_exporter/xlsx/xlsx_fill_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const xlsxFillHelper = {
return result;
},

tryCreateFillFromSimpleFormat: function({ backgroundColor, patternStyle, patternColor } = {}) {
if(isDefined(backgroundColor) && !(isDefined(patternStyle) && isDefined(patternColor))) {
tryCreateFillFromSimpleFormat: function({ backgroundColor, fillPatternType, fillPatternColor } = {}) {
if(isDefined(backgroundColor) && !(isDefined(fillPatternType) && isDefined(fillPatternColor))) {
return {
patternFill: {
patternType: 'solid',
Expand All @@ -24,12 +24,12 @@ const xlsxFillHelper = {
}
}
};
} else if(isDefined(patternStyle) && isDefined(patternColor)) {
} else if(isDefined(fillPatternType) && isDefined(fillPatternColor)) {
return {
patternFill: {
patternType: patternStyle,
patternType: fillPatternType,
foregroundColor: {
rgb: patternColor
rgb: fillPatternColor
},
backgroundColor: {
rgb: backgroundColor
Expand All @@ -43,11 +43,11 @@ const xlsxFillHelper = {
if(source.backgroundColor !== undefined) {
target.backgroundColor = source.backgroundColor;
}
if(source.patternStyle !== undefined) {
target.patternStyle = source.patternStyle;
if(source.fillPatternType !== undefined) {
target.fillPatternType = source.fillPatternType;
}
if(source.patternColor !== undefined) {
target.patternColor = source.patternColor;
if(source.fillPatternColor !== undefined) {
target.fillPatternColor = source.fillPatternColor;
}
},

Expand Down
Loading

0 comments on commit ce70a15

Please sign in to comment.