Telerik Radgrid export file name

yogi picture yogi · Jun 13, 2012 · Viewed 11.1k times · Source

Does any one know how to provide file name to the exported file in Telerik RadGrid, Exported file could be of any format pdf, excel or word

Answer

Niranjan Singh picture Niranjan Singh · Jun 13, 2012

Source: Grid / MS Excel/MS Word/CSV

Use RadGrid.ExportSettings.FileName property, a string specifying the name (without the extension) of the file that will be created. The file extension is automatically added based on the method that is used Try setting the FileName in the ItemCommand event as shown below.

From: When to set RadGrid.ExportSettings.FileName

protected void Radgrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToPdfCommandName)
    {
        Radgrid1.ExportSettings.FileName = "yourfilename";
    }
    if (e.CommandName == RadGrid.ExportToExcelCommandName)
    {
        Radgrid1.ExportSettings.FileName = "yourfilename";
    }
    if (e.CommandName == RadGrid.ExportToWordCommandName)
    {
        Radgrid1.ExportSettings.FileName = "yourfilename";
    }
}

Reference:
Export RadGrid content to Excel/Word/CSV/PDF with Ajax enabled