Ejemplo n.º 1
0
        private void AsyncExport(object param)
        {
            var grid   = param as RadGridView;
            var dialog = new SaveFileDialog()
            {
                DefaultExt = this.SelectedExportFormat,
                Filter     = String.Format("(*.{0})|*.{1}", this.SelectedExportFormat, this.SelectedExportFormat)
            };

            if (dialog.ShowDialog() == true)
            {
                switch (this.SelectedExportFormat)
                {
                case "xlsx":
                    GridViewSpreadStreamExport spreadStreamXlsxExport = new GridViewSpreadStreamExport(grid);
                    spreadStreamXlsxExport.ShowLoadingIndicatorWhileAsyncExport = this.ShowLoadingIndicatorWhileAsyncExport;
                    spreadStreamXlsxExport.RunExportAsync(dialog.FileName.ToString(), new SpreadStreamExportRenderer());
                    break;

                case "csv":
                    GridViewSpreadStreamExport spreadStreamCsvExport = new GridViewSpreadStreamExport(grid);
                    spreadStreamCsvExport.ExportFormat = SpreadStreamExportFormat.Csv;
                    spreadStreamCsvExport.RunExportAsync(dialog.FileName.ToString(), new SpreadStreamExportRenderer());
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void AsyncExportDefaultStyles(object param)
        {
            var grid          = param as RadGridView;
            var exportOptions = new GridViewSpreadStreamExportOptions()
            {
                ExportDefaultStyles = true,
                ShowColumnFooters   = grid.ShowColumnFooters,
                ShowColumnHeaders   = grid.ShowColumnHeaders,
                ShowGroupFooters    = grid.ShowGroupFooters
            };

            var dialog = new SaveFileDialog()
            {
                DefaultExt = this.SelectedExportFormat,
                Filter     = String.Format("(*.{0})|*.{1}", this.SelectedExportFormat, this.SelectedExportFormat)
            };

            if (dialog.ShowDialog() == true)
            {
                switch (this.SelectedExportFormat)
                {
                case "xlsx":
                    GridViewSpreadStreamExport spreadStreamXlsxExport = new GridViewSpreadStreamExport(grid);
                    spreadStreamXlsxExport.ShowLoadingIndicatorWhileAsyncExport = this.ShowLoadingIndicatorWhileAsyncExport;
                    spreadStreamXlsxExport.ElementExportingToDocument          += (s, e) =>
                    {
                        if (e.Element != SpreadStreamExportElement.Cell)
                        {
                            e.Style = new SpreadStreamCellStyle()
                            {
                                IsBold = true, FontSize = 12, Background = (Color)ColorConverter.ConvertFromString("#FFF2F2F2")
                            };
                        }
                    };
                    spreadStreamXlsxExport.RunExportAsync(dialog.FileName.ToString(), new SpreadStreamExportRenderer(), exportOptions);
                    break;

                case "csv":
                    GridViewSpreadStreamExport spreadStreamCsvExport = new GridViewSpreadStreamExport(grid);
                    spreadStreamCsvExport.ExportFormat = SpreadStreamExportFormat.Csv;
                    spreadStreamCsvExport.RunExportAsync(dialog.FileName.ToString(), new SpreadStreamExportRenderer());
                    break;
                }
            }
        }