Hi,
I am able to style my cells in FlexSheet but when I do export to excel those styles are not exported.
private dynamicFlexSheetInitialize(flexSheet: wjcGridSheet.FlexSheet, e: wjcCore.EventArgs) {
const grid = new wjcGrid.FlexGrid(document.createElement(‘div’), {
itemsSource: this.dynamicCountryFlexSheetData,
columns:[
{binding: ‘id’, header: ‘ID #’, width: 40},
{binding: ‘country’, header: ‘Country’},
{binding: ‘name’, header: ‘Security Name’, width: ‘*’},
{binding: ‘active’, header: ‘Active’, width: 60},
{binding: ‘amount’, header: ‘Amount ($)’, width: 80},
{binding: ‘date’, header: ‘Date’, width: 90},
],
});
const countrySheet = new wjcGridSheet.Sheet(flexSheet, grid, ‘Country’);
//fix for by default first cell is selected
countrySheet.grid.select(new wjcGrid.CellRange());
flexSheet.sheets.push(countrySheet);
flexSheet.beginUpdate();
const gridPanel = countrySheet.grid.cells;
//console.log(gridPanel.rows.length);
for(let r = 0 ; r < gridPanel.rows.length; r++) {
const row: wjcGrid.Row = gridPanel.rows[r];
const dataItem = row.dataItem;
let columnIndex = 0;
for(columnIndex = 0 ; columnIndex < gridPanel.columns.length; columnIndex++ ) {
if(columnIndex === 1) {
//country column
if(dataItem.country === 'US') {
flexSheet.applyCellsStyle(
{
backgroundColor: 'orange'
},
[
new wjcGrid.CellRange(row.index + 1, 1, row.index + 1, 1 )
]
);
}
}
}
}
flexSheet.endUpdate();
flexSheet.itemFormatter = (panel: any, row: number, column: number, cell) => {
//get underline bind object
const dataItem = flexSheet.rows[row]._data;
cell.addEventListener('contextmenu', (e: MouseEvent) => {
if(row === 0) {
e.preventDefault();
e.stopImmediatePropagation();
} else if(row > 0) {
const wjColumn = this.wjFlexSheetColumns[column];
if(dataItem !== null && dataItem !== undefined &&
dataItem.contextmenu !== undefined && dataItem.contextmenu !== null) {
if(dataItem.contextmenu === false) {
e.preventDefault();
e.stopImmediatePropagation();
} else {
this.dynamicContextMenuItems = [];
this.dynamicContextMenuItems = wjColumn.contextMenuItems;
}
} else {
e.preventDefault();
e.stopImmediatePropagation();
}
}
}, true);
if(row === 0) {
const columnSort = panel.columns[column].currentSort;
const header = wjcCore.toHeaderCase(panel.columns[column].binding);
switch (columnSort) {
case '+':
cell.innerHTML = header + '<span class="wj-glyph-up" style="float:right;margin:5px;"></span>';
break;
case '-':
cell.innerHTML = header + '<span class="wj-glyph-down" style="float:right;margin:5px;"></span>';
break;
default:
cell.innerHTML = header;
}
//flexSheet.columns[column].header = 'xxxx';
if(column !== 0 && column !== 5) {
cell.innerHTML = '<div>' + flexSheet.columns[column].header +
'<div style="width:auto;float:right;"><span class="wj-glyph-filter"></span></div></div>';
cell.firstElementChild.onclick = function () {
flexSheet.showColumnFilter();
}
}
}
};
}