Skip to content

Commit

Permalink
ExcelJS - implement 'wrapText' option
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyKiyashko committed Jan 26, 2020
1 parent d5d19ac commit 1c088db
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 316 deletions.
10 changes: 7 additions & 3 deletions js/exporter/exceljs/exportDataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function exportDataGrid(options) {
autoFilterEnabled,
keepColumnWidths,
selectedRowsOnly,
wrapText,
loadPanel
} = _getFullOptions(options);

Expand Down Expand Up @@ -58,7 +59,7 @@ function exportDataGrid(options) {
for(let rowIndex = 0; rowIndex < dataRowsCount; rowIndex++) {
const row = worksheet.getRow(cellsRange.from.row + rowIndex);

_exportRow(rowIndex, columns.length, row, cellsRange.from.column, dataProvider, customizeCell, headerRowCount, mergedCells, mergeRanges);
_exportRow(rowIndex, columns.length, row, cellsRange.from.column, dataProvider, customizeCell, headerRowCount, mergedCells, mergeRanges, wrapText);

if(rowIndex >= headerRowCount) {
row.outlineLevel = dataProvider.getGroupLevel(rowIndex);
Expand Down Expand Up @@ -119,11 +120,14 @@ function _getFullOptions(options) {
if(!isDefined(fullOptions.autoFilterEnabled) && isDefined(fullOptions.component)) {
fullOptions.autoFilterEnabled = !!fullOptions.component.option('export.excelFilterEnabled');
}
if(!isDefined(fullOptions.wrapText)) {
fullOptions.wrapText = false;
}

return fullOptions;
}

function _exportRow(rowIndex, cellCount, row, startColumnIndex, dataProvider, customizeCell, headerRowCount, mergedCells, mergeRanges) {
function _exportRow(rowIndex, cellCount, row, startColumnIndex, dataProvider, customizeCell, headerRowCount, mergedCells, mergeRanges, wrapText) {
const styles = dataProvider.getStyles();

for(let cellIndex = 0; cellIndex < cellCount; cellIndex++) {
Expand All @@ -134,7 +138,7 @@ function _exportRow(rowIndex, cellCount, row, startColumnIndex, dataProvider, cu
excelCell.value = cellData.value;

if(isDefined(excelCell.value)) {
const { bold, alignment, wrapText, format, dataType } = styles[dataProvider.getStyleId(rowIndex, cellIndex)];
const { bold, alignment, format, dataType } = styles[dataProvider.getStyleId(rowIndex, cellIndex)];

let numberFormat = _tryConvertToExcelNumberFormat(format, dataType);
if(isDefined(numberFormat)) {
Expand Down
Loading

0 comments on commit 1c088db

Please sign in to comment.