I am exporting content from a RadGrid. With the default settings, the grid data exports perfectly. As soon as I make a change to any of the ExportSettings, I get a blank spreadsheet in Excel. Has anyone else run into this problem?
I have an OnBubbleEvent setup in my Grid class. When the user has clicked "Export Grid" from the GridToolBar inside the Grid CommandItemTemplate, I bubble the event up to the grid. Eventually, the parameters are passed into the OnBubbleEvent which simply calls the code below:
I have an OnBubbleEvent setup in my Grid class. When the user has clicked "Export Grid" from the GridToolBar inside the Grid CommandItemTemplate, I bubble the event up to the grid. Eventually, the parameters are passed into the OnBubbleEvent which simply calls the code below:
| protected void CreateExportFile(string[] exportResults) |
| { |
| //Hide the GridToolBar |
| this.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; |
| //Hide the Pager |
| this.MasterTableView.PagerStyle.Visible = false; |
| //Hide the PreviewIcon Column |
| foreach (GridColumn col in this.MasterTableView.Columns) |
| { |
| if (col.ColumnType == "GridTemplateColumn") |
| { |
| col.Visible = false; |
| } |
| } |
| //Hide the ExpandColumn |
| (this.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem)["ExpandColumn"].Visible = false; |
| foreach (GridDataItem dataItem in this.MasterTableView.Items) |
| { |
| dataItem["ExpandColumn"].Style["display"] = "none"; |
| dataItem["ExpandColumn"].Visible = false; |
| } |
| switch (exportResults[0]) |
| { |
| case "Excel": |
| { |
| SetExportSettings(exportResults); |
| this.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.Html; |
| this.MasterTableView.ExportToExcel(); |
| this.MasterTableView.Rebind(); |
| break; |
| } |
| case "Word": |
| { |
| SetExportSettings(exportResults); |
| this.MasterTableView.ExportToWord(); |
| break; |
| } |
| case "CSV": |
| { |
| SetExportSettings(exportResults); |
| this.MasterTableView.ExportToCSV(); |
| break; |
| } |
| } |
| } |
| private void SetExportSettings(string[] exportParameters) |
| { |
| //0=Format, 1=IncludeColumnNames, 2=IgnorePaging, 3=OpenInNewWindow |
| this.ExportSettings.ExportOnlyData = false;// !(Convert.ToBoolean(exportParameters[1])); //IncludeColumnNames |
| this.ExportSettings.IgnorePaging = true; // Convert.ToBoolean(exportParameters[2]); //IgnorePaging |
| this.ExportSettings.OpenInNewWindow = true; // Convert.ToBoolean(exportParameters[3]); //OpenInNewWindow |
| } |