0
votes

To display my data in grid I used a few template columns.

I have mutiple fields to display, like : Name - Surname. But for doing an export as excel file, I need to split that information into 2 columns. To apply filter in excel export..

<telerik:GridTemplateColumn UniqueName="PRD_exp" Exportable="true"
                            HeaderText="Info1<br/>Info2" >
    <ItemTemplate>
        <%#((myDataTYPE)Container.DataItem).Info1 %>
        <br/>-<br/>
        <%#((myDataTYPE)Container.DataItem).Info2 %>
    </ItemTemplate>
</telerik:GridTemplateColumn>

In my excel export I want that information to be in two different columns. So I have set visibility of template column to Exportable="false", and created it as a hidden column by making visible="false" for each data.

Like this:

<telerik:GridBoundColumn DataField="Info1" UniqueName="Info1"
                         Exportable="true"  Visible="false" />
<telerik:GridBoundColumn DataField="Info2" UniqueName="Info2"
                         Exportable="true"  Visible="false" />

How can this be achieved, with the rad export?

1

1 Answers

1
votes

Do the change in your export button click event.

adding GridUser.MasterTableView.GetColumn("Info1").Display=true will do the trick.

protected void btnExport_Click(object sender, EventArgs e)
{
    GridUser.ExportSettings.FileName = "ExportedFile;
    GridUser.MasterTableView.GetColumn("Info1").Display =true;
    GridUser.MasterTableView.GetColumn("Info2").Display = true; 
    GridUser.ExportSettings.Excel.Format = (GridExcelExportFormat)Enum.Parse(typeof(GridExcelExportFormat), "Xlsx");
    GridUser.ExportSettings.IgnorePaging = true;
    GridUser.ExportSettings.ExportOnlyData = true;
    GridUser.ExportSettings.OpenInNewWindow = true;
    GridUser.MasterTableView.ExportToExcel();
}