Example #1
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (ExportOption.ExportFilterOption == RadExportFilterOption.RADGRIDVIEW_PRINT_FILTER)
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    ExportOption.RichTextBox.Document = PDFExporter.CreateDocument(ExportOption.Element as RadGridView
                                                                                   , ExportOption.SkipColumnDisplayIndex, ExportOption.CellValueOverwrite, ExportOption.ColumnAggregateOverwrite
                                                                                   , ExportOption.InitialHeaderBlock);
                }));

                ExportOption.RichTextBox.Document.SectionDefaultPageOrientation = PageOrientation.Landscape;
                ExportOption.RichTextBox.Print(ExportOption.ElementName, Telerik.Windows.Documents.UI.PrintMode.Native);

                this.DialogResult = true;
            }
            else if (ExportOption.ExportFilterOption == RadExportFilterOption.RADCHART_PRINT_FILTER)
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    ExportOption.RichTextBox.Document = PDFExporter.PrintChart(ExportOption.Element as RadChart);
                }));

                ExportOption.RichTextBox.Document.SectionDefaultPageOrientation = PageOrientation.Landscape;
                ExportOption.RichTextBox.Print(ExportOption.ElementName, Telerik.Windows.Documents.UI.PrintMode.Native);
                this.DialogResult = true;
            }
            else
            {
                SaveFileDialog dialog = new SaveFileDialog()
                {
                    DefaultExt = ".xls",
                    Filter     = RadExportFilterOptionDesc.GetEnumDescription(ExportOption.ExportFilterOption)
                };

                if (dialog.ShowDialog() == true)
                {
                    RadGridView_ElementExport.ExportElementOptions = ExportElementOptionsInfo;
                    RadExport.ExportStream(dialog.FilterIndex, ExportOption, dialog.OpenFile(), ExportOption.SkipColumnDisplayIndex
                                           , ExportOption.CellValueOverwrite, ExportOption.ColumnAggregateOverwrite, initialHeaderBlock: ExportOption.InitialHeaderBlock);
                    this.DialogResult = true;
                }
                else
                {
                    this.DialogResult = false;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Exports RadGrid and RadChart to stream
        /// </summary>
        /// <param name="filterIndex">defines the index of filter specified for extension of file exported to</param>
        /// <param name="exportOption">RadExportOptions</param>
        /// <param name="stream">Stream</param>
        public static void ExportStream(int filterIndex, RadExportOptions exportOption, Stream stream, List <int> skipColumnDisplayIndex = null
                                        , Func <int, int, object, object, object> cellValueOverwrite = null, Func <int, int, string> columnAggregateOverWrite = null
                                        , Func <Block> initialHeaderBlock = null)
        {
            switch (exportOption.ExportFilterOption)
            {
            case RadExportFilterOption.RADGRIDVIEW_EXCEL_EXPORT_FILTER:
            {
                switch (filterIndex)
                {
                case 1:
                    RadExport.ExportRadGridViewXLS(exportOption.Element, stream);
                    break;

                case 2:
                    RadExport.ExportRadGridViewXML(exportOption.Element, stream);
                    break;

                case 3:
                    RadExport.ExportRadGridViewCSV(exportOption.Element, stream);
                    break;

                case 4:
                    RadExport.ExportRadGridViewDOC(exportOption.Element, stream);
                    break;

                default:
                    RadExport.ExportRadGridViewXLS(exportOption.Element, stream);
                    break;
                }
            }
            break;

            case RadExportFilterOption.RADCHART_EXCEL_EXPORT_FILTER:
            {
                switch (filterIndex)
                {
                case 1:
                    RadExport.ExportRadChartXLS(exportOption.Element, stream);
                    break;

                case 2:
                    RadExport.ExportRadChartPNG(exportOption.Element, stream);
                    break;

                case 3:
                    RadExport.ExportRadChartBMP(exportOption.Element, stream);
                    break;

                default:
                    RadExport.ExportRadChartXLS(exportOption.Element, stream);
                    break;
                }
            }
            break;

            case RadExportFilterOption.RADGRIDVIEW_PDF_EXPORT_FILTER:
                RadExport.ExportRadGridViewPDF(exportOption.Element, stream, skipColumnDisplayIndex, cellValueOverwrite
                                               , columnAggregateOverWrite, initialHeaderBlock);
                break;

            case RadExportFilterOption.RADCHART_PDF_EXPORT_FILTER:
                RadExport.ExportRadChartPDF(exportOption.Element, stream);
                break;

            default:
                break;
            }
            stream.Close();
        }