(1) I used dataBound event to change some color of the cell in the grid. How can I put that color to the excel as well?
(2) I have changed the title name of a column with "<br />" to show 2 lines and it is successful in grid. But in excel, it just show "<br />". How can I do the same during export to excel?
Thanks.
$("#gdCombinedReport").kendoGrid({
dataSource: reportDataSource,
sortable: false,
pageable: false,
scrobllable: true,
toolbar: ["excel"],
dataBound: onDataBound3,
excel: {
fileName: "Report.xlsx",
allPages: true
},
columns: [
{ field: "itemName", title: "Item Name", locked: true, attributes: { style: "text-align:left" }, width: "200px" },
{ field: "forecast[0]", title: $scope.titleName[0] + "<br /> January", attributes: { style: "text-align:right" }, width: "90px", format: "{0:c0}" },
7 Answers, 1 is accepted
I will go straight to the questions:
1. You could use an approach similar to the following one in the excelExport event in order to set custom background color to the Grid cells.
2. The reason for this behavior is that Excel does not support HTML, so <br/> cannot be translated to new row. Nevertheless allowing this in the upcoming versions is in our development plans.
I wish you a great day!
Regards,
Telerik

(1) Besides changing background color, I want to bold some cells and do number format as $1,000 as well. I tried but failed. How can I do that?
(2) Also, I tried to export to pdf but my kendo grid has horizontal scrollbar. Is it possible to have pdf for the whole grid. Thanks.
row.cells[cellIndex].Font.Bold = true;
row.cells[cellIndex].format(c0);
row.cells[cellIndex].NumberFormat = "#,##0";
row.cells[cellIndex].value = (row.cells[cellIndex].value).replace(/\d(?=(\d{3})+\.)/g, '$&,');
You could find all the possible configuration options for the Workbook at the following documentation page. For example:
sheets.rows.cells.boldsheets.rows.cells.format
Regarding the second question, indeed at the moment only the visible rows are exported to PDF. As a workaround, you could use the following approach. In the example I am temporary increasing the height of the Grid, so that all of the rows are exported and then returning the old one. Currently we are in the process of developing a more convenient way to achieve this.
I wish you a great day!
Regards,
Dimiter Madjarov
Telerik


1) With existing code, content did not show after horizontal scroll bar.
2) first frozen column only show rows on the screen, missing rows underneath
3) vertical rows only show for the first pdf page, it did not go to next page.
I tried the following but it didn't work. Is there any workaround? Thanks.
var wrapperWidth = grid.wrapper.css("width");
var contentWidth = $(".k-grid-content", grid.wrapper).css("width");
...
grid.wrapper.css("width", wrapperWidth);
$(".k-grid-content", grid.wrapper).css("width", contentWidth);
Hello Bertha,
The reason that the rows from the frozen columns are not shown with the current custom implementation is that they are part of a different table element and we are not modifying it's height before exporting, The example could be modified like this, in order to update the locked content height accordingly too.
Nevertheless at the moment I cannot provide a suitable workaround for the other issues. It is in our development plans to provide better PDF export options in complex scenarios like the current one.
I wish you a great day!
Regards,Dimiter Madjarov
Telerik
