Sagar Shinde
Sagar Shinde

Reputation: 160

Kendo export excel missing $ sign

I am using kendo export to excell functionality and by using columns.Bound(x => x.TotalAccountValue).Format("{0:c}"); this code I am able to see $ sign in Grid but when I am trying to export $ sign is missing in Excel export.

Upvotes: 1

Views: 423

Answers (1)

Ali Hassan
Ali Hassan

Reputation: 79

When you are going to export GRID in Excel in kendo. Here is a working example of how to edit the header and how to format the each column value.

This Example might be helpful for you.

excelExport: function (event) {  
  var sheet = event.workbook.sheets[0];
  var firstRow = sheet.rows[0];

  //Excel output - create a header row
  $("#grid .k-grid-header .k-link").each(function (i) { //for each column header in the grid...
      firstRow.cells[i].value = $(this).text(); //set cell text from grid column text
      firstRow.cells[i].background = "#0070C0"; //set cell to "blue" color
  });


  //Excel output - column formatting
  var formatColMask = null;

  for (var rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) { //begin on first row (skip header)
      var row = sheet.rows[rowIndex]; //get each row from Excel file

      for (var colIndex = 0; colIndex < row.cells.length; colIndex++) { //for each row, check each cell by field name

            switch (this.columns[colIndex].field) {
                case "Field1":
                    formatColMask = "###,##0";
                    break;
                case "Field2":
                    formatColMask = "$#,##0";
                    break;
                case "Field3":
                    formatColMask = "$#,##0";
                    break;
                default:
                    break;
            }
            row.cells[colIndex].format = formatColMask; //apply column format mask
        }
    }
},

Upvotes: 0

Related Questions