2
votes

I'm using Kendo UI grid and I want to export the grid data to excel file. I want that the data will be displayed from right to left (It's currently displayed ltr). How can I do that?

Thanks, Yael

2

2 Answers

0
votes

Wire ExcelExport Event to the function below:

function onExcelExport(e) {
        var sheet = e.workbook.sheets[0];
        for (var i = 0; i < sheet.rows.length; i++) {
            sheet.rows[i].cells.reverse();    
            for (var ci = 0; ci < sheet.rows[i].cells.length; ci++) {
                sheet.rows[i].cells[ci].hAlign = "right";
                sheet.rows[i].cells[ci].fontFamily = "tahoma";
                sheet.rows[i].cells[ci].textAlign = "center";
            }
        }
    }

It's not the best solution but it's the closest so far.

0
votes

in the excelExport of grid config add this code :

e.workbook.rtl = true

 toolbar: ["excel"],
            excel: {
              allPages: true
            },
      excelExport: function(e) {
              var workbook = e.workbook;
              var sheet = workbook.sheets[0];
              workbook.rtl = true;
              for (var i = 0; i < sheet.rows.length; i++) {
                for (var ci = 0; ci < sheet.rows[i].cells.length; ci++) {
                  sheet.rows[i].cells[ci].hAlign = "right";
                }
              }
            },