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

Grid Export to Excel (Built-in bug vs Custom)

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christophe
Top achievements
Rank 1
Christophe asked on 19 Jun 2013, 06:23 AM
Hi there,

I'm using RadGrid and its ExportToExcel feature. I tried both approach of using the built-in button by setting OnBiffExporting="ExportList" and :
<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"
    ShowRefreshButton="true" />
 and create my own:
<telerik:RadButton ID="rbtIGTExportToExcel" Width="150px" Text="Export To Excel" OnClick="btnExcel_Click"
    runat="server" Icon-PrimaryIconUrl="~/images/icons/sys-excel.png" />

Both are calling similar methods:
  1. Built-in version:
protected void ExportList(object sender, EventArgs e)
{
    RadGridListAllUser.ExportSettings.IgnorePaging = true;
    RadGridListAllUser.ExportSettings.OpenInNewWindow = true;
    RadGridListAllUser.ExportSettings.FileName = string.Format("{0} User List Export {1}", (string)Session["StudyName"], DateTime.Now.ToShortDateString());
    RadGridListAllUser.MasterTableView.ExportToExcel();
}

2. Custom version:
protected void btnExcel_Click(object sender, EventArgs e)
{
    rgIGTSummaryGrid.ExportSettings.IgnorePaging = true;
    rgIGTSummaryGrid.ExportSettings.OpenInNewWindow = true;
    rgIGTSummaryGrid.ExportSettings.FileName = string.Format("{0} IGT Export {1}", (string)Session["StudyName"], DateTime.Now.ToShortDateString());
    rgIGTSummaryGrid.MasterTableView.ExportToExcel();
}


In both version the FileName property is set but only the custom version ends up with this name, the built-in one keeps spitting a  RadGridExport.xls. Plus, in the custom version, all forbidden characters such as : / & < > are automatically replaced by _ which doesn't happen with the built-in feature.

Is this a bug or am I doing something wrong ?

Cheers,

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jun 2013, 06:26 AM
Hi,

I have tried your code, but i didn't find the file name property issue.Both the inbuilt and custom file names are displayed.
Here is the code i tried.

C#:
protected void RadGrid1_ItemCommand1(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToExcelCommandName)
    {
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.FileName = ("Data&Excel");
        RadGrid1.MasterTableView.ExportToExcel();
    }
}
 
protected void btnExcel_Click(object sender, EventArgs e)
{
    RadGrid1.ExportSettings.IgnorePaging = true;
    RadGrid1.ExportSettings.OpenInNewWindow = true;
    RadGrid1.ExportSettings.ExportOnlyData = true;
    RadGrid1.ExportSettings.FileName = ("Data&buttonExcel");
    RadGrid1.MasterTableView.ExportToExcel();
}

Thanks,
Princy
Tags
Grid
Asked by
Christophe
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or