Excel Export Missing Data in Dynamic GridTemplateColumn and Header Text Changing

3 posts, 0 answers
  1. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 18 Oct 2010 Link to this post

    Hi,
    We are using 2010 Q1 SP1.
    We have enebled excel export on a dynamically created grid (few columns are GridTemplateColumn and others are GridBoundColumn) and added programmatically on runtime.
    If we make ExportOnlyData="true" and Format="Html" or ExcelML then it do not exports GridTemplateColumn columns.

    If we make ExportOnlyData="false" and Format="Html" then it exports all data in all columns but it makes Columns headers as Links in exported file.

    Is there any way to make grid to export data with ExportOnlyData="true" and Format="Html" or to remove link tag from the exported excel.

    Thanks

  2. Imran Javed Zia
    Imran Javed  Zia avatar
    55 posts
    Member since:
    Jul 2009

    Posted 18 Oct 2010 Link to this post

    protected void grd_GridExporting(object source, GridExportingArgs e)
    {
        e.ExportOutput = Regex.Replace(e.ExportOutput, "<a[^>]+>", "", RegexOptions.IgnoreCase);
        e.ExportOutput = Regex.Replace(e.ExportOutput, "</a>", "", RegexOptions.IgnoreCase);
    }

    Hi,
    I have used this code to remove link tags from the exported file. It is is serving as per expectations, I have not tested it thoroughly and hope there is some better way too for this directly provided by Telerik.  
    Thanks
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 21 Oct 2010 Link to this post

    Hello Imran,

    You can also replace the buttons with plain text on ItemCreated:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem && isExport)
        {
            foreach (TableCell cell in e.Item.Cells)
            {
                if (cell.HasControls())
                    cell.Text = (cell.Controls[0] as IButtonControl).Text;
            }
        }
    }

    Word/Excel export (HTML-based)

    Regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top