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

Excel Export Missing Data in Dynamic GridTemplateColumn and Header Text Changing

2 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Imran Javed Zia
Top achievements
Rank 1
Imran Javed Zia asked on 18 Oct 2010, 01:39 PM

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 Answers, 1 is accepted

Sort by
0
Imran Javed Zia
Top achievements
Rank 1
answered on 18 Oct 2010, 03:17 PM
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
0
Daniel
Telerik team
answered on 21 Oct 2010, 10:15 PM
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
Tags
Grid
Asked by
Imran Javed Zia
Top achievements
Rank 1
Answers by
Imran Javed Zia
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or