Excel Export hidden columns

1 Answer 2332 Views
Grid
Thien
Top achievements
Rank 1
Thien asked on 15 Dec 2014, 07:14 PM
Hello I am starting to play with the excel export functionality and looking through the online documentation but could not find how to export hidden columns. Is there a way to do this using the mvc wrappers? 

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 16 Dec 2014, 11:34 AM
Hi Thien,

Please refer to the following thread, which discusses the reverse scenario - how to hide a column during export. The algorithm in your case will be practically the same.

http://www.telerik.com/forums/export-to-grid-hide-columns

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Thien
Top achievements
Rank 1
commented on 18 Dec 2014, 07:51 PM

Hello Dimo thanks. Its now working as expected.
Pankaj
Top achievements
Rank 1
Veteran
commented on 03 Jun 2015, 06:16 PM

hello Dimo .

I have one hidden column in grid .I want to show this column in excel export and hide one no hidden column .here is my code.

  @(Html.Kendo().Grid<CRSWebApp.Models.AuditReportModel>()
                        .Name("gridAuditReport")
                                .Columns(columns =>
                                {
                                    columns.Bound(p => p.CRSReportAuditKey).Title("ID").HtmlAttributes(new { @class = "grid-column-yellow" });
                                    columns.Bound(p => p.ADUserName).Title("User").HtmlAttributes(new { @class = "grid-column-yellow" });
                                    columns.Bound(p => p.ReportName).Title("Report Name").HtmlAttributes(new { @class = "grid-column-yellow" });
                                    columns.Bound(p => p.SearchCriteria).Title("Search Criteria").Width("40%").HtmlAttributes(new { @class = "grid-column-yellow" });
                                    columns.Bound(p => p.ReportStartDate).Title("Start Date").Format("{0:MM/dd/yyyy H:mm:ss}").Hidden(true);
                                    columns.Bound(p => p.ReportStartDateTime).Title("Start Date").ClientTemplate("#=kendo.toString(ReportStartDate,'g')#")
                                        .Format("{0:MM/dd/yyyy H:mm:ss}").HtmlAttributes(new { @class = "grid-column-yellow" });

                                })

                        .ToolBar(tools => tools.Excel().HtmlAttributes(new { style = "float:left;" }))                       
                        .Pageable(e => e.Refresh(true).PageSizes(true).ButtonCount(5))
                        .Sortable()
                        .Filterable(ftb => ftb.Mode(GridFilterMode.Menu)
                                    .Operators(o => o.ForString(s => s
                                            .Clear()
                                            .Contains("Contains")
                                            .IsEqualTo("Is equal to")
                                            .IsNotEqualTo("Is not equal to")
                                            .StartsWith("Starts with")
                                            .EndsWith("Ends with")
                                            )))

                        .Scrollable(s => s.Height("auto"))
                        .Resizable(resize => resize.Columns(true))
                        .Excel(excel => excel
                                    .FileName("BIReport.xlsx")                                    
                                    .AllPages(true)
                                    .Filterable(true)
                                    .ProxyURL(Url.Action("Excel_Export_Save", "Admin"))
                                )                                
                        .Reorderable(a => a.Columns(true))
                        .Mobile(MobileMode.Auto)

                        .Selectable(selectable => selectable
                                                    .Mode(GridSelectionMode.Single)
                                                    .Type(GridSelectionType.Cell))
                                                                .Events(e => e.DataBound("onAuditReportRowBound").ExcelExport("ExcelExportEvent"))//   .ColumnResize("adjustLastColumn"))
                        .DataSource(dataSource => dataSource
                                        .Ajax()
                                        .PageSize(20)
                                        .Events(events => events.Error("error_handler"))
                                        .ServerOperation(true)
                                                .Read(read => read.Action("GetGridAuditReports", "Admin")
                                                                        .Data("getAdditionalData('" + Model.AuditReportStartDate + "','"
                                                                                                    + Model.AuditReportEndDate + "')")))



    )

and

 

function ExcelExportEvent(e) {       
        e.sender.showColumn("ReportStartDate");
        e.sender.hideColumn("ReportStartDateTime");      
    }

 

but it is not working in excel export.

Dimo
Telerik team
commented on 04 Jun 2015, 01:10 PM

Hi Pankaj,

You don't seem to have implemented any of my suggestions in the linked forum thread above.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Pankaj
Top achievements
Rank 1
Veteran
commented on 04 Jun 2015, 02:30 PM

Hello,

           I did it .i have seen your solution ...I was doing some mistake . Thnaks for your reply.

        

Tags
Grid
Asked by
Thien
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or