protected override void Invoke(object parameter)
        {
            if (parameter is SelectionChangedEventArgs)
            {
                SelectionChangedEventArgs eventArgs = parameter as SelectionChangedEventArgs;
                ComboBox comboBox = eventArgs.OriginalSource as ComboBox;
                ExportAsPivotTable = comboBox.SelectedIndex == 1;
            }
            else if (parameter is RoutedEventArgs)
            {
                try
                {
                    RoutedEventArgs eventArgs    = parameter as RoutedEventArgs;
                    Button          exportButton = eventArgs.OriginalSource as Button;
                    SaveFileDialog  savedialog   = new SaveFileDialog();
                    savedialog.AddExtension = true;
                    savedialog.FileName     = "Sample";
                    switch (exportButton.Content.ToString())
                    {
                    case "Export To Excel":
                        savedialog.DefaultExt = "xlsx";
                        savedialog.Filter     = "Excel file (.xlsx)|*.xlsx";

                        if (savedialog.ShowDialog() == true)
                        {
                            GridExcelExport excelExport = new GridExcelExport(this.Target, Syncfusion.XlsIO.ExcelVersion.Excel2007);
                            excelExport.ExportMode = ExportAsPivotTable ? ExportModes.PivotTable : ExportModes.Cell;
                            excelExport.Export(savedialog.FileName);
                            MessageBox.Show("Excel sheet exported successfully!");
                        }
                        break;

                    case "Export To PDF":
                        savedialog.DefaultExt = "pdf";
                        savedialog.Filter     = "Pdf file (.pdf)|*.pdf";

                        if (savedialog.ShowDialog() == true)
                        {
                            GridPdfExport pdfExport = new GridPdfExport(this.Target);
                            pdfExport.Export(savedialog.FileName);
                            MessageBox.Show("PDF document exported successfully!");
                        }
                        break;

                    case "Export To Word":
                        savedialog.DefaultExt = "Doc";
                        savedialog.Filter     = "Word file (.Doc)|*.Doc";
                        if (savedialog.ShowDialog() == true)
                        {
                            GridWordExport wordExport = new GridWordExport(this.Target);
                            wordExport.Export(savedialog.FileName);
                            MessageBox.Show("Word document exported successfully!");
                        }
                        break;

                    case "Export To CSV":
                        savedialog.DefaultExt = "CSV";
                        savedialog.Filter     = "Csv file (.csv)|*.csv";
                        if (savedialog.ShowDialog() == true)
                        {
                            GridCsvExport csvExport = new GridCsvExport(this.Target);
                            csvExport.Delimiter = ",";
                            csvExport.Export(savedialog.FileName);
                            MessageBox.Show("CSV document exported successfully!");
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while exporting." + Environment.NewLine + "Exception Message: " + ex.Message, "Error on export", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        private void DoExport(object parm)
        {
            if (parm != null)
            {
                if (parm.ToString().Equals("Export to Excel"))
                {
                    try
                    {
                        SaveFileDialog savedialog = new SaveFileDialog();
                        savedialog.AddExtension = true;
                        savedialog.FileName     = "Sample";
                        savedialog.DefaultExt   = "xls";
                        savedialog.Filter       = "Excel file (.xls)|*.xls";

                        if (savedialog.ShowDialog() == true)
                        {
                            GridExcelExport gridExcelExport = new GridExcelExport(this.GridDataManager.PivotEngine, this.ExportGridStyleInfo, this.GridLayout, savedialog.DefaultExt, false);
                            gridExcelExport.Export(savedialog.FileName);
                            MessageBox.Show("Exported successfully!.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error on Excel export.\nException Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace, "Export error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if (parm.ToString().Equals("Export to Word"))
                {
                    try
                    {
                        SaveFileDialog savedialog = new SaveFileDialog();
                        savedialog.AddExtension = true;
                        savedialog.FileName     = "Sample";
                        savedialog.DefaultExt   = "Doc";
                        savedialog.Filter       = "Word file (.Doc)|*.Doc";
                        if (savedialog.ShowDialog() == true)
                        {
                            GridWordExport gridWordExport = new GridWordExport(this.GridDataManager.PivotEngine, this.GridLayout);
                            gridWordExport.Export(savedialog.FileName, this.ExportGridStyleInfo);
                            MessageBox.Show("Exported successfully!.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error on Word export.\nException Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace, "Export error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if (parm.ToString().Equals("Export to Pdf"))
                {
                    try
                    {
                        SaveFileDialog savedialog = new SaveFileDialog();
                        savedialog.AddExtension = true;
                        savedialog.FileName     = "Sample";
                        savedialog.DefaultExt   = "pdf";
                        savedialog.Filter       = "Pdf file (.pdf)|*.pdf";

                        if (savedialog.ShowDialog() == true)
                        {
                            GridPdfExport gridPdfExport = new GridPdfExport(this.GridDataManager.PivotEngine, this.ExportGridStyleInfo);
                            gridPdfExport.Export(savedialog.FileName);
                            MessageBox.Show("Exported successfully!.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error on PDF export.\nException Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace, "Export error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if (parm.ToString().Equals("Export to CSV"))
                {
                    try
                    {
                        SaveFileDialog savedialog = new SaveFileDialog();
                        savedialog.AddExtension = true;
                        savedialog.FileName     = "Sample";
                        savedialog.DefaultExt   = "CSV";
                        savedialog.Filter       = "Csv file (.csv)|*.csv";
                        if (savedialog.ShowDialog() == true)
                        {
                            GridCsvExport gridCsvExport = new GridCsvExport(this.GridDataManager.PivotEngine);
                            gridCsvExport.Export(savedialog.FileName);
                            MessageBox.Show("CSV document exported successfully!.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error on CSV export.\nException Message: " + ex.Message + "\nStack Trace: " + ex.StackTrace, "Export error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }