jQuery UI Widgets Forums Grid Excel export number format

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 5 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Excel export number format #63185

    andy8
    Participant

    Hi everybody,

    When exporting grids with float number formats to Excel, cells in the Excel spreadsheet are being formatted as integer, i.e. with 0 decimal places. To get it fixed, I have to highlight the related Excel cells and explicitly set up their format to 5-6 decimal places as in the original Grid.

    Are their any settings to control this issue, i.e. set Excel number formats during export?

    Thanks

    Excel export number format #63189

    Dimitar
    Participant

    Hello andy8,

    Please make sure you have set the appropriate cellsformat to your float number column (e.g. cellsformat: "f2"). You can see how to export such a column correctly in the demo Data Export.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Excel export number format #63325

    andy8
    Participant

    Hello Dimitar,

    The cells are rendered as jqxInputNumber editor. The example of such column:

    	var getNumCol = function(gridID,ttl,dfld, minv,maxv,clname,w,dec,hdn,inpmode){
    		if(clname === undefined)clname = "";
    		if(w === undefined)w = 80;
    		if(inpmode === undefined)inpmode = 'simple';
    		if(dec === undefined)dec = 4;
    		if(hdn === undefined)hdn = false;
    		var wObj = {
    			text: ttl,
    			width: w,
    			//cellsformat: 'f4',
    			columntype: 'custom',
    			align: 'right',
    			cellclassname: clname,
    			datafield: dfld,
    			cellsalign: 'right',
    			hidden: hdn,
    			createeditor: function(row, cellvalue, editor, cellText, width, height){
    				editor.jqxNumberInput({
    					decimalDigits: dec,
    					inputMode: inpmode,
    					max: maxv,
    					min: minv,					
    					theme: theme,
    					value: 0,
    					width: width,
    					height: height,
    					spinButtons: true,
    					spinMode: 'advanced'
    				});
    				editor.on('valuechanged', function (event) {
    					if (currentRow == -1) currentRow = row;
    					var value = editor.val();
    					if (typeof gridID == 'string'){
    						$(gridID).jqxGrid('setcellvalue', currentRow, dfld, value);
    					}else{
    						gridID.jqxGrid('setcellvalue', currentRow, dfld, value);
    					}				
    				});			
    			},
    			initeditor: function (row, cellvalue, editor, celltext, pressedkey) {
    				currentRow = row;
    				if(cellvalue === undefined){
    					var v = 0;
    				}else{
    					var v = parseFloat(cellvalue);
    				}
    				editor.jqxNumberInput({
    					decimal: v
    				});
    			},
    			geteditorvalue: function (row, cellvalue, editor) {
    				return editor.val();
    			}
    		};
    		return [wObj];	
    	}

    If I add a property cellsformat: "f2", the jqxNumberInput doesn’t work: jqxgrid.edit.js generates an error: TypeError: Object has no method ‘indexOf’

    It looks like adding cells formats to column property conflicts with jqxNumberInput.

    Any sugestions?

    Excel export number format #63351

    Dimitar
    Participant

    Hi andy8,

    jqxNumberInput is one of the default, supported editors. You just need to set columntype to “numberinput” (demo). This way, you may not even need the implementations of createeditor, initeditor and geteditorvalue, which may cause the issue.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.