You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exporting group data, we encountered an issue where the group row header is exported as an empty string in the output file. This issue occurs when using:
import{DataGenerator,XlsProviderBase,Grid,Toast,Column,ColumnStore}from'../../build/grid.module.js?481612';importsharedfrom'../_shared/shared.module.js?481612';consttypeMap={string : String,number : Number,date : Date,boolean : Boolean,bool : Boolean};classCustomWidgetColumnextendsColumn{static$name='CustomWidgetColumn';statictype='CustomWidget';onCellClick({
grid,
record,
target
}){console.log("test");}}// Register ColumnColumnStore.registerColumnType(CustomWidgetColumn);// This is a custom provider class which uses more styling on cells based on certain conditionsclassCustomExcelFileProviderextendsXlsProviderBase{// This method is called by the exporter feature to write the filestaticwrite({ filename, columns, rows }){rows.forEach(row=>{row.forEach(cell=>{// Convert cell type as library expects itcell.type=typeMap[cell.type]||String;if(cell.type===String&&typeofcell.value!=='string'){cell.value=`${cell.value}`;}if(cell.type===Number){constindex=columns.findIndex(col=>col.field==='firstName');// Style cells based on valueif(cell.value<30){cell.backgroundColor='#FFFF00';// Style the name cell in the same rowif(index!==-1){row[index].fontWeight='bold';}}elseif(cell.value>70){cell.backgroundColor='#FF0000';if(index!==-1){row[index].fontStyle='italic';}}}});});// Columns are just the first line of the data containing column headerscolumns.map(cell=>{// Delete type, header is always textdeletecell.type;deletecell.field;// Style the header cellcell.fontWeight='bold';cell.align='center';});globalThis.writeXlsxFile(// data starts with array of header and is followed by the actual data[columns, ...rows],{dateFormat : 'yyyy-mm-dd',fileName : filename,columns : columns.map(cell=>{return{// write-excel-file library expects width in characters, we receive with in pixelswidth : Math.round((cell.width||100)/10)};})});}}constgrid=newGrid({appendTo : 'container',selectionMode: {multiSelect: true,// Enable multiple row selectiondragSelect: true,selectOnKeyboardNavigation: true,deselectOnClick: true,row: false,//Prevent selection of row and marking the checkbox as selected when clicked anywhere on the row except the checkboxcheckbox: {// These configs are applied to the checkbox selection columnid: 'checkbox_all',checkCls: 'b-my-checkbox',align: 'center',hidden: false,hideable: false,// Set to false to prevent the user from hiding the columnresizable: false,groupable: false,filterable: false,exportable: false},showCheckAll: true},features : {excelExporter : {// disable date format to keep date instancedateFormat : null,xlsProvider : CustomExcelFileProvider}},// Headers will ripple on tap in Material themeripple : {delegate : '.b-grid-header'},columns : [{id: 'stop_watch',cls: 'text-center hidden-xs',flex: 3,type: 'widget',align: 'center',text: '',icon: 'fa-thin fa-stopwatch',htmlEncode: false,cellCls: 'hidden-xs',hideable: false,// Set to false to prevent the user from hiding the columnresizable: false,filterable: false,groupable: false,exportable: false,headerRenderer: ({
column,
headerElement
})=>{return'Stop Widget';},renderer: ({
record,
isExport
})=>{varrendererConfig={};rendererConfig['html']=``;returnrendererConfig;}},{id: 'start_time',cls: 'text-center hidden-xs timerHeader',flex: 5,align: 'center',type: 'CustomWidget',text: 'Start custom widget',icon: 'glyphicon glyphicon-play',htmlEncode: false,cellCls: 'hidden-xs',hideable: true,// Set to false to prevent the user from hiding the columnresizable: false,filterable: false,groupable: false,sortable: false,exportable: false,renderer: ({
record
})=>{varhtml_content="";html_content=``;returnhtml_content;}},{text : 'Name',field : 'name',flex : 2,editor : {type : 'textfield',required : true}},{text : 'Age',field : 'age',width : 100,type : 'number'},{text : 'City',field : 'city',flex : 1},{text : 'Start',field : 'start',flex : 1,type : 'date'},{text : 'Food',field : 'food',flex : 1},{text : 'Color (not sortable)',field : 'color',flex : 1,sortable : false,renderer({ cellElement, value, isExport }){// During export cellElement might be missingif(!isExport){// renderer that sets text color = textcellElement.style.color=value;}returnvalue;}}],data : DataGenerator.generateData(50),tbar : [{type : 'button',text : 'Export (default settings)',icon : 'b-fa b-fa-file-excel',ref : 'excelExportBtn1',onAction : ()=>grid.features.excelExporter.export()},{type : 'button',text : 'Export (custom columns)',icon : 'b-fa b-fa-file-excel',ref : 'excelExportBtn2',onAction : ()=>grid.features.excelExporter.export({exporterConfig : {columns : [{text : 'First Name',field : 'firstName',width : 90},{text : 'Age',field : 'age',width : 40},{text : 'Starts',field : 'start',width : 140},{text : 'Ends',field : 'finish',width : 140}]}})},{type : 'button',text : 'Export to CSV',icon : 'b-fa b-fa-file-csv',ref : 'excelExportBtn3',onAction : ()=>grid.features.excelExporter.export({csv : {delimiter : ','}})}]});
Screenshots:
The text was updated successfully, but these errors were encountered:
Forum Post
When exporting group data, we encountered an issue where the group row header is exported as an empty string in the output file. This issue occurs when using:
This is the example where we tested this, https://bryntum.com/products/grid/examples/exporttoexcel/
Screenshots:
The text was updated successfully, but these errors were encountered: