Telerik Radgrid export file name

不想你离开。 提交于 2019-12-10 13:48:56

问题


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


回答1:


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




回答2:


You can set the filename as well as other options for exporting, on the ExportSettings property of the grid (not the MasterTableView). So for example:

myGrid.ExportSettings.FileName = "file";
myGrid.ExportSettings.Excel.Extension = "xls";
myGrid.MasterTableView.ExportToExcel();


来源:https://stackoverflow.com/questions/11012161/telerik-radgrid-export-file-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!