private void Export(object param)
        {
            this.SetCulture();

            IWorkbookFormatProvider formatProvider = FileHelper.GetFormatProvider(this.selectedExportFormat);
            if (formatProvider == null)
            {
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = String.Format("{0} files|*{1}|All files (*.*)|*.*", this.selectedExportFormat,
                formatProvider.SupportedExtensions.First());

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    Workbook workbook = this.CreateWorkbook(this.GridView);
                    formatProvider.Export(workbook, stream);
                }
            }

            this.RestoreCulture();
        }
Ejemplo n.º 2
0
        public static void PromptAndExportEntities(IEnumerable entitiesToExport, string[] properties)
        {
            //            Dim stream As IO.Stream = Nothing
            System.IO.Stream stream = null;

            // SaveFileDialog() must be opened on the UI thread
            Dispatchers.Main.Invoke(() =>
            {
                System.Windows.Controls.SaveFileDialog dlg = new System.Windows.Controls.SaveFileDialog();
                dlg.Filter = "CSV Files (*.csv)|*.csv|Text Files (*.txt)|*.txt";
                dlg.DefaultExt = "csv";

                if (dlg.ShowDialog() == true)
                {
                    stream = dlg.OpenFile();
                }
            });

            if (stream != null)
            {
                PerformExport(stream, entitiesToExport, properties);

                // Need to close the file on the UI thread as well
                Dispatchers.Main.Invoke(() =>
                {
                    stream.Close();
                });

            }
        }
        private void Export(object param)
        {
            if (!this.quartersToExport.Values.Contains(true))
            {
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = String.Format("{0} files|*.{1}|{2} files|*.{3}", "Pdf", "pdf", "Text", "txt");

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    RadFixedDocument document = this.CreateDocument();
                    switch (dialog.FilterIndex)
                    {
                        case 1:
                            PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
                            pdfFormatProvider.Export(document, stream);
                            break;
                        case 2:
                            using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
                            {
                                TextFormatProvider textFormatProvider = new TextFormatProvider();
                                writer.Write(textFormatProvider.Export(document));
                            }
                            break;
                    }
                }
            }
        }