Thanks for sharing that idea for a built-in feature!
Currently, one way to set the name of the sheet in the exported Excel file is by using the InfrastructureExporting event of RadGrid.
Sample C# code:
protected void RadGrid1_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
{
ExportStructure.ExportStructure structure = e.ExportStructure;
// Render the structure to XLSX format and return it to a byte array
ExportStructure.XlsxRenderer renderer = new ExportStructure.XlsxRenderer(structure);
byte[] xlsxByteArray = renderer.Render();
// create an format provider instance
XLSX.XlsxFormatProvider formatProvider = new XLSX.XlsxFormatProvider();
// import the newly created document into a Workbook
WB.Workbook myWorkbook = formatProvider.Import(xlsxByteArray);
myWorkbook.Worksheets[0].Name = "MySheet";
// once finished with changes convert the workbook back to byte array
byte[] data = formatProvider.Export(myWorkbook);
// return the byte array for downloading.
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.Headers.Remove("Content-Disposition");
Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", RadGrid1.ExportSettings.FileName));
Response.BinaryWrite(data);
Response.End();
}
Related resources:
Kind regards,
Doncho
Progress Telerik