Esempio n. 1
0
        public void ExportGrid(ExportType fileType)
        {
            switch (fileType)
            {
            case ExportType.XLSX:
                SaveFileDialogService.DefaultExt = "xlsx";
                SaveFileDialogService.Filter     = "Excel 2007+|*.xlsx";
                break;

            case ExportType.PDF:
                SaveFileDialogService.DefaultExt = "pdf";
                SaveFileDialogService.Filter     = "PDF|*.pdf";
                break;
            }

            if (SaveFileDialogService.ShowDialog())
            {
                var fileName = SaveFileDialogService.GetFullFileName();
                ExportService.ExportTo(fileType, fileName);
                if (MessageBoxService.ShowMessage("Would you like to open the file?", "Export finished",
                                                  MessageButton.YesNo) == MessageResult.Yes)
                {
                    Process.Start(fileName);
                }
            }
        }
        /// <summary>
        /// Export Grid
        /// </summary>
        /// <param name="fileType"></param>
        public void ExportGrid(ExportType fileType)
        {
            try
            {
                switch (fileType)
                {
                case ExportType.XLSX:
                    SaveFileDialogService.DefaultExt = "xlsx";
                    SaveFileDialogService.Filter     = "Excel 2007+|*.xlsx";
                    break;

                case ExportType.PDF:
                    SaveFileDialogService.DefaultExt = "pdf";
                    SaveFileDialogService.Filter     = "PDF|*.pdf";
                    break;
                }

                if (SaveFileDialogService.ShowDialog())
                {
                    var fileName = SaveFileDialogService.GetFullFileName();
                    ExportGridService.ExportTo(fileType, fileName);
                    if (MessageBoxService.ShowMessage("¿Desea abrir el archivo?", "Operación Exitosa", MessageButton.YesNo) == MessageResult.Yes)
                    {
                        var process = new Process();
                        process.StartInfo.UseShellExecute = true;
                        process.StartInfo.FileName        = fileName;
                        process.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxService.ShowMessage(GetStringValue(Next.Enums.Enums.MessageError.ExportError), ex.Message);
            }
        }
Esempio n. 3
0
 public void Export()
 {
     SaveFileDialogService.Filter = "PDF files (*.pdf)|*.pdf";
     if (SaveFileDialogService.ShowDialog())
     {
         IsBusy = true;
         ExportToPdf(serverConnection, SaveFileDialogService.GetFullFileName(), SelectedReportObject.Id);
     }
 }
Esempio n. 4
0
        public void ExportToExcel()
        {
            SaveFileDialogService.Filter = "Excel files (*.xlsx)|*.xlsx";
            if (SaveFileDialogService.ShowDialog())
            {
                IXlExporter exporter    = XlExport.CreateExporter(XlDocumentFormat.Xlsx);
                string[]    columnNames = new string[] { "Word", "Definition" };
                string      fileName    = SaveFileDialogService.GetFullFileName();

                using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite))
                {
                    using (IXlDocument document = exporter.CreateDocument(stream))
                    {
                        using (IXlSheet sheet = document.CreateSheet())
                        {
                            sheet.Name = "Dictionary";

                            using (IXlColumn column = sheet.CreateColumn())
                            {
                                column.WidthInCharacters    = 25;
                                column.Formatting           = new XlCellFormatting();
                                column.Formatting.Alignment = new XlCellAlignment();
                                column.Formatting.Alignment.VerticalAlignment = XlVerticalAlignment.Center;
                            }

                            using (IXlColumn column = sheet.CreateColumn())
                            {
                                column.WidthInCharacters             = 100;
                                column.Formatting                    = new XlCellFormatting();
                                column.Formatting.Alignment          = new XlCellAlignment();
                                column.Formatting.Alignment.WrapText = true;
                            }

                            IXlTable table;
                            using (IXlRow row = sheet.CreateRow())
                                table = row.BeginTable(columnNames, true);

                            foreach (DictionaryBookmark bookmark in DictionaryBookmarksView)
                            {
                                using (IXlRow row = sheet.CreateRow())
                                    row.BulkCells(new string[] { bookmark.Word, bookmark.Definition }, null);
                            }

                            using (IXlRow row = sheet.CreateRow())
                                row.EndTable(table, false);

                            table.Style.ShowFirstColumn = true;
                        }
                    }
                }

                Process.Start(fileName);
            }
        }
Esempio n. 5
0
        public void ExportToPdf(IPrintableControl control)
        {
            PrintableControlLink link = new PrintableControlLink(control);

            link.Margins = new Margins(50, 50, 50, 50);

            if (ExportHelper.Export(ExportFormat.Pdf, link.PrintingSystem) == true)
            {
                SaveFileDialogService.Filter = "PDF File (.pdf)|*.pdf";

                if (SaveFileDialogService.ShowDialog())
                {
                    link.ExportToPdf(SaveFileDialogService.GetFullFileName());
                    OpenExternalApplication(SaveFileDialogService.GetFullFileName());
                }
            }
        }
        public void Export(ExportType type)
        {
            switch (type)
            {
            case ExportType.PDF:
                SaveFileDialogService.Filter = "PDF files|*.pdf";
                if (SaveFileDialogService.ShowDialog())
                {
                    ExportService.ExportToPDF(SaveFileDialogService.GetFullFileName());
                }
                break;

            case ExportType.XLSX:
                SaveFileDialogService.Filter = "Excel 207 files|*.xlsx";
                if (SaveFileDialogService.ShowDialog())
                {
                    ExportService.ExportToPDF(SaveFileDialogService.GetFullFileName());
                }
                break;
            }
        }