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

[Solved] Error when setting ExportSettings

1 Answer 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Richard asked on 03 Apr 2009, 07:40 PM
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:

 

        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=Format1=IncludeColumnNames2=IgnorePaging3=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  
        }  
 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Apr 2009, 08:47 AM
Hi Richard,

I reviewed your code and unfortunately I could not determine where could be the problem based on the given information. Please examine this online demo and verify that you implemented correctly the export functionality.

If the problem still persists, I suggest you to prepare a simple working test project which reproduces the erroneous behavior. Thus I will do all my best to find a quick solution/fix of this abnormality.

Looking forward for your reply. 

Kind regards,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Richard
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or