Esempio n. 1
0
        public static void ExportGridToExcel(RadGridView gridViewExport)
        {
            string extension = ".xls";

            /*
             * SaveFileDialog dialog = new SaveFileDialog()
             * {
             *  DefaultExt = extension,
             *  Filter = String.Format("{1} files (.{0})|.{0}|All files (.)|.", extension, "Excel"),
             *  FilterIndex = 1
             * };
             *
             * if (dialog.ShowDialog() == true)
             */


            var of = new RadSaveFileDialog();

            of.Owner            = MainClass.MainAppwindow;
            of.InitialDirectory = Properties.Settings.Default.LastDirectory;
            of.ShowDialog();
            of.ExpandToCurrentDirectory = false;
            // of.Filter = String.Format("{1} files (.{0})|.{0}|All files (.)|.", extension, "Excel");
            if (of.DialogResult.GetValueOrDefault())
            {
                Properties.Settings.Default.LastDirectory = of.FileName;
                Properties.Settings.Default.Save();

                using (Stream stream = new FileStream(of.FileName + extension, FileMode.Create))
                {
                    gridViewExport.Export(stream,
                                          new GridViewExportOptions()
                    {
                        Format            = ExportFormat.ExcelML,
                        ShowColumnHeaders = true,
                        ShowColumnFooters = true,
                        ShowGroupFooters  = false,
                    });
                }
            }



            /*
             * {
             *  //  using (Stream stream = dialog.OpenFile())
             *  using (Stream stream = new FileStream(@"D:/rep1.xls",FileMode.Create))
             *  {
             *      gridViewExport.Export(stream,
             *       new GridViewExportOptions()
             *       {
             *           Format = ExportFormat.ExcelML,
             *           ShowColumnHeaders = true,
             *           ShowColumnFooters = true,
             *           ShowGroupFooters = false,
             *       });
             *  }
             * }
             */
        }
        private void ExportToExcel(RadGridView gv)
        {
            string            extension = "xls";
            RadSaveFileDialog dialog    = new RadSaveFileDialog()
            {
                DefaultExt  = extension,
                Filter      = String.Format("{1} files (.{0})|.{0}|All files (.)|.", extension, "Excel"),
                FilterIndex = 1
            };

            if (dialog.ShowDialog() == true)
            {
                using (Stream stream = dialog.OpenFile())
                {
                    gv.Export(stream,
                              new GridViewExportOptions()
                    {
                        Format            = ExportFormat.Html,
                        ShowColumnHeaders = true,
                        ShowColumnFooters = true,
                        ShowGroupFooters  = false,
                    });
                }
            }
        }
Esempio n. 3
0
        private void OnSaveAsFile(object sender, ExecutedRoutedEventArgs e)
        {
            var dialog = new RadSaveFileDialog();

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile()) {
                    Editor.Document.SaveFile(stream, Encoding.UTF8, LineTerminator.Newline);
                }

                FilePath = dialog.FileName;
            }
        }
Esempio n. 4
0
        private void EventButtonNewFileName(object sender, EventArgs e)
        {
            RadSaveFileDialog DxNewFile = new RadSaveFileDialog();

            DxNewFile.InitialDirectory = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
            DxNewFile.FileName         = Program.ApplicationSettings.NewFileName;
            DialogResult result = DxNewFile.ShowDialog();

            if (result == DialogResult.OK)
            {
                TxCreateDatabase.Text = DxNewFile.FileName;
            }
        }
Esempio n. 5
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            RadSaveFileDialog saveFileDialog = new RadSaveFileDialog()
            {
                Filter = "Diagram Documents (*.diagram)|*.diagram" +
                         "|All Files (*.*)|*.*",
                FilterIndex = 0
            };

            //saveFileDialog.FileName = storageFile != null ? storageFile.Name : null;
            saveFileDialog.ShowDialog();
            if (saveFileDialog.DialogResult == true)
            {
                var path = saveFileDialog.FileName;
                Save(diagram, path);
            }
        }
Esempio n. 6
0
        public CombinerViewModel()
        {
            openFileDialog = new RadOpenFileDialog {
                Owner = Application.Current.MainWindow, ExpandToCurrentDirectory = false
            };
            openFileDialog.Filter      = "PDF Documents|*.pdf";
            openFileDialog.Multiselect = true;

            saveFileDialog = new RadSaveFileDialog {
                Owner = Application.Current.MainWindow, ExpandToCurrentDirectory = false
            };
            saveFileDialog.Filter = "PDF Documents|*.pdf";

            AddItemCommand      = new DelegateCommand(AddItem);
            ClearCommand        = new DelegateCommand(ClearItems);
            CombineItemsCommand = new DelegateCommand(CombineItems);

            ItemsToMerge.CollectionChanged += ItemsToMerge_CollectionChanged;
        }
Esempio n. 7
0
        void exp()
        {
            RadOpenFolderDialog openFolderDialog = new RadOpenFolderDialog();

            openFolderDialog.ShowDialog();
            this.storage.FolderName = openFolderDialog.FileName;
            RadOpenFileDialog radOpenFileDialog = new RadOpenFileDialog()
            {
                Filter = "Word Documents (*.doc)|*.doc|Excel Worksheets (*.xls;*.xlsx)|*.xls;*.xlsx|PowerPoint Presentations (*.ppt)|*.ppt" +
                         "|Office Files (*.doc;*.xls;*.ppt)|*.doc;*.xls;*.ppt" +
                         "|All Files (*.*)|*.*",
                FilterIndex = 5,
            };

            radOpenFileDialog.ShowDialog();
            RadSaveFileDialog saveFileDialog = new RadSaveFileDialog()
            {
                Filter = "Word Documents (*.doc)|*.doc|Excel Worksheets (*.xls;*.xlsx)|*.xls;*.xlsx|PowerPoint Presentations (*.ppt)|*.ppt" +
                         "|Office Files (*.doc;*.xls;*.ppt)|*.doc;*.xls;*.ppt" +
                         "|All Files (*.*)|*.*",
                FilterIndex = 5,
            };

            //saveFileDialog.FileName = storageFile != null ? storageFile.Name : null;
            saveFileDialog.ShowDialog();
            if (saveFileDialog.DialogResult == true)
            {
            }

            //this.explorer.Filter = "Word Documents|*.doc;*.docx|Excel Worksheets|*.xls;*.xlsx|PowerPoint Presentations|*.ppt;*.pptx" +
            //                            "|Office Files|*.doc;*.docx*.xls;*.xlsx;*.ppt*.pptx" +
            //                            "|Image Files|*.jpg;*.png;*.bmp" +
            //                            "|Text Files|*.txt;" +
            //                            "|Archives Files|*.zip;*.rar" +
            //                            "|All Files|*.*";
        }
Esempio n. 8
0
        private void SaveFile(object parameter)
        {
            string            extension    = null;
            Stream            outputStream = null;
            RadSaveFileDialog saveDialog   = new RadSaveFileDialog();
            string            exportFormat = parameter as string;

            if (exportFormat != null && exportFormat.Contains("|"))
            {
                saveDialog.Filter = exportFormat;
            }
            else
            {
                var formatProviders = DocumentFormatProvidersManager.FormatProviders;

                if (!string.IsNullOrEmpty(exportFormat))
                {
                    string[] extensions = exportFormat.Split(',', ';').Select(e => e.Trim('.').ToLower()).ToArray();
                    formatProviders = formatProviders.Where(fp => fp.SupportedExtensions.Any(ext => extensions.Contains(ext.Trim('.').ToLower())));
                }

                string filter = string.Join("|", formatProviders.Where(fp => fp.CanExport)
                                            .OrderBy(fp => fp.Name)
                                            .Select(fp => FileHelper.GetFilter(fp))
                                            .ToArray());
                saveDialog.Filter = filter;
            }

            bool?dialogResult = saveDialog.ShowDialog();

            if (dialogResult == true)
            {
                extension    = System.IO.Path.GetExtension(saveDialog.FileName);
                outputStream = saveDialog.OpenFile();

                IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);

                if (provider == null)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnsupportedFileFormat"));
                    return;
                }

                if (provider is IConfigurablePdfFormatProvider)
                {
                    IConfigurablePdfFormatProvider pdfFormatProvider = (IConfigurablePdfFormatProvider)provider;
                    pdfFormatProvider.ExportSettings.CommentsExportMode =
                        this.radRichTextBox.ShowComments ? PdfCommentsExportMode.NativePdfAnnotations : PdfCommentsExportMode.None;
                }

                try
                {
                    using (outputStream)
                    {
                        provider.Export(this.radRichTextBox.Document, outputStream);
                        this.SetDocumentName(saveDialog.FileName);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(LocalizationManager.GetString("Documents_SaveCommand_UnableToSaveFile"));
                }
            }
        }