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

Including new lines in kendo grid excel export

5 Answers 266 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RYAN
Top achievements
Rank 1
RYAN asked on 07 Jan 2016, 02:06 PM

Hello,

 I am using a client-side solution to export kendo grid data to Excel.  I would like to be able to include line breaks within each cell.  \r, \n, <br />, and &#10; don't work.  Here's some sample code:

// ...
excelExport: function (e) {
        var sheet = e.workbook.sheets[0];
        var skillsIndex = 0;
 
        // First row.  Find the skills column, and set the index.
        for (var i = 0; i < sheet.rows[0].cells.length; i++)
        {
            if (sheet.rows[0].cells[i].value == "Skills")
            {
                skillsIndex = i;
                break;
            }
        }
 
        for (var j = 1; j < sheet.rows.length; j++)
        {
            sheet.rows[j].cells[skillsIndex].value = "We got&#10;skills!";
            // doesn't break the line between got and skills -- how to do so?
        }
}
// ...

Thank you for any help you can provide!

5 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 11 Jan 2016, 08:19 AM
Hello Ryan,

You could enable the wrap property of the cell in order to wrap the text.

http://docs.telerik.com/kendo-ui/api/javascript/ooxml/workbook#configuration-sheets.rows.cells.wrap

Let me know if this was the information that you were looking for.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
RYAN
Top achievements
Rank 1
answered on 11 Jan 2016, 03:02 PM
That worked.  Thank you!
0
Rod
Top achievements
Rank 1
answered on 17 Dec 2019, 07:15 PM

ooxml wrap: true worked great for me in a project using v2016.1.112

However, when I upgraded to v2019.3.1023, without changing code, wrap stopped working.

{
   value: data[i].Notes, wrap: true, verticalAlign: "top", fontSize: 14, bold: fntBold, borderBottom: { color: "steelblue", size: 1 },
   borderLeft: { color: "steelblue", size: 1 }, borderRight: { color: "steelblue", size: 1 }, borderTop: { color: "steelblue", size: 1 },  
},

0
Rod
Top achievements
Rank 1
answered on 18 Dec 2019, 03:38 PM

Appears that there is more info on this issue, evidently still unresolved, here

https://www.telerik.com/forums/excel-export---line-breaks-in-cell-not-appearing-in-spreadsheet#oxlTwIJD20m6tT3tOk2ZPQ

 

0
Petar
Telerik team
answered on 19 Dec 2019, 03:05 PM

Hi Rod,

Based on the written by my colleague Alex in the linked thread, the reported issue should be fixed as of the R3 2018 release.

Can you send me a Dojo example or a runnable project in which the behavior you have in the upgraded project can be reproduced? Once I can reproduce the reported issue, I will be able to provide feedback about it. 

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
RYAN
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
RYAN
Top achievements
Rank 1
Rod
Top achievements
Rank 1
Petar
Telerik team
Share this question
or