This is a migrated thread and some comments may be shown as answers.

Export to Excel - Footer as Number, Not String

1 Answer 644 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kencox
Top achievements
Rank 1
kencox asked on 28 Apr 2018, 08:28 PM

Hey folks,

When I export my grid to Excel, the client footer value is formatted as a string (see the Excel image below).

Is it possible to tell Excel that this is a numeric value?

Thanks,

Ken

columns.Bound(e => e.Total).Title("Amount").Width(120).Format("{0:C}").ClientFooterTemplate("#= kendo.format('{0:c}', sum)#");

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 01 May 2018, 09:05 AM
Hello, Ken,

To get the Kendo UI Grid Excel Export footer to generate a cell like the rest of the numeric cells, you should add a handler to the excelExport event and parse the value of the cell to a float. You may use the kendo.parseFloat() method:

excelExport: function(e){
  var rows = e.workbook.sheets[0].rows;
 
  for (var ri = 0; ri < rows.length; ri++) {
    var row = rows[ri];
 
    if (row.type == "footer") {
      for (var ci = 0; ci < row.cells.length; ci++) {
        var cell = row.cells[ci];
        if (cell.value) {
          cell.value = kendo.parseFloat(cell.value);
        }
      }
    }
  }
},
 
Here is a runnable example for your convenience:

https://dojo.telerik.com/@bubblemaster/IsIRuHEL

Let me know if you need further assistance.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
kencox
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or