Example #1
0
 private void UpdatePreview()
 {
     if (previewExport != null)
     {
         TextExport textExport = Export as TextExport;
         ReportPage page       = textExport.Report.PreparedPages.GetPage(int.Parse(tbPage.Text) - 1);
         previewExport.PageBreaks = cbPageBreaks.Checked;
         previewExport.DataOnly   = cbDataOnly.Checked;
         previewExport.Frames     = cbbFrames.SelectedIndex != 0;
         previewExport.TextFrames = cbbFrames.SelectedIndex == 1;
         previewExport.EmptyLines = cbEmptyLines.Checked;
         if (cbbCodepage.SelectedIndex == 0)
         {
             previewExport.Encoding = Encoding.Default;
         }
         else if (cbbCodepage.SelectedIndex == 1)
         {
             previewExport.Encoding = Encoding.UTF8;
         }
         else if (cbbCodepage.SelectedIndex == 2)
         {
             previewExport.Encoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage);
         }
         previewExport.ScaleX    = (float)udX.Value;
         previewExport.ScaleY    = (float)udY.Value;
         tbPreview.Text          = previewExport.ExportPage(page);
         lblPageWidthValue.Text  = previewExport.PageWidth.ToString();
         lblPageHeightValue.Text = previewExport.PageHeight.ToString();
         lblLoss.Visible         = !previewExport.DataSaved;
     }
 }
Example #2
0
        public override void Init(ExportBase export)
        {
            base.Init(export);
            TextExport textExport = Export as TextExport;

            report = textExport.Report;

            ProfessionalColorTable vs2005ColorTable = new ProfessionalColorTable();

            vs2005ColorTable.UseSystemColors = true;
            toolStrip.Renderer = new ToolStripProfessionalRenderer(vs2005ColorTable);

            cbPageBreaks.Checked = textExport.PageBreaks;
            cbEmptyLines.Checked = textExport.EmptyLines;
            if (textExport.Frames && textExport.TextFrames)
            {
                cbbFrames.SelectedIndex = 1;
            }
            else if (textExport.Frames && !textExport.TextFrames)
            {
                cbbFrames.SelectedIndex = 2;
            }
            else
            {
                cbbFrames.SelectedIndex = 0;
            }
            cbDataOnly.Checked = textExport.DataOnly;
            if (textExport.Encoding == Encoding.Default)
            {
                cbbCodepage.SelectedIndex = 0;
            }
            else if (textExport.Encoding == Encoding.UTF8)
            {
                cbbCodepage.SelectedIndex = 1;
            }
            else if (textExport.Encoding == Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage))
            {
                cbbCodepage.SelectedIndex = 2;
            }
            udX.Value = (decimal)textExport.ScaleX;
            udY.Value = (decimal)textExport.ScaleY;

            udX.ValueChanged += new EventHandler(udX_ValueChanged);
            udY.ValueChanged += new EventHandler(udX_ValueChanged);
            cbbFrames.SelectedIndexChanged += new EventHandler(cbbFrames_SelectedIndexChanged);

            MyRes res = new MyRes("Preview");

            tbPage.Text        = "1";
            prevPage           = 1;
            lblTotalPages.Text = String.Format(Res.Get("Misc,ofM"), report.PreparedPages.Count);

            cbFontSize.SelectedIndex = 4;

            previewExport             = new TextExport();
            previewExport.PreviewMode = true;
            CalcScale();
        }
Example #3
0
        protected override ExportBase CreateExporter()
        {
            var res = new TextExport
            {
                PageBreaks = false,
                EmptyLines = false,
                DataOnly   = false,
                Frames     = false,
                Encoding   = new UnicodeEncoding()
            };

            return(res);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;

            // select export format type
            switch (identificator)
            {
            case EXPORT_EXTENSION_HTM:
            case EXPORT_TYPE_NAME_HTM:
                export = new HtmlExport();
                break;

            case EXPORT_EXTENSION_PDF:
            case EXPORT_TYPE_NAME_PDF:
                export = new PdfExport();
                break;

            case EXPORT_EXTENSION_RTF:
            case EXPORT_TYPE_NAME_RTF:
                export = new RtfExport();
                break;

            case EXPORT_EXTENSION_TIF:
            case EXPORT_TYPE_NAME_TIF:
                export = new TiffExport();
                break;

            case EXPORT_EXTENSION_TXT:
            case EXPORT_TYPE_NAME_TXT:
                export = new TextExport();
                break;

            case EXPORT_EXTENSION_XLS:
            case EXPORT_TYPE_NAME_XLS:
                export = new XlsExport();
                break;

            default:
                Debug.Assert(false);     // NOTE: not supported
                break;
            }

            return(export);
        }
        public static FileStreamResult ToCsvResult(this DataDynamics.ActiveReports.Document.Document reportDocument, string name)
        {
            // Do not close or dispose MemoryStream as the FileStreamResult disposes it after use
            var memoryStream = new MemoryStream();

            using (var exported = new TextExport())
            {
                exported.TextDelimiter = ",";
                exported.Export(reportDocument, memoryStream);

                memoryStream.Flush();
                memoryStream.Seek(0, SeekOrigin.Begin);

                var fileStreamResult = new FileStreamResult(memoryStream, "application/csv");

                fileStreamResult.FileDownloadName = string.Format("{0}.csv", name);

                return(fileStreamResult);
            }
        }
Example #6
0
        private void CalcScale()
        {
            TextExport textExport = Export as TextExport;

            using (ProgressForm progressForm = new ProgressForm(null))
            {
                progressForm.Show();
                MyRes res = new MyRes("Export,Text");
                progressForm.ShowProgressMessage(res.Get("ScaleMessage"));
                textExport.EmptyLines = cbEmptyLines.Checked;
                textExport.Frames     = cbbFrames.SelectedIndex != 0;
                textExport.TextFrames = cbbFrames.SelectedIndex == 1;
                textExport.DataOnly   = cbDataOnly.Checked;
                textExport.ScaleX     = (float)udX.Value;
                textExport.ScaleY     = (float)udY.Value;
                textExport.CalculateScale(progressForm);
                udX.Value = (decimal)Math.Round(textExport.ScaleX, 2);
                udY.Value = (decimal)Math.Round(textExport.ScaleY, 2);
            }
            UpdatePreview();
        }
Example #7
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            TextExport parentExport = Export as TextExport;
            TextExport textExport   = new TextExport();

            using (TextExportPrintForm printDialog = new TextExportPrintForm(textExport))
            {
                textExport.PrinterTypes = parentExport.PrinterTypes;
                textExport.Copies       = parentExport.Copies;
                printDialog.CurrentPage = tbPage.Text;

                if (printDialog.ShowDialog() == DialogResult.OK)
                {
                    if (cbbCodepage.SelectedIndex == 1)
                    {
                        cbbCodepage.SelectedIndex = 2;
                    }
                    textExport.PageBreaks = cbPageBreaks.Checked;
                    textExport.EmptyLines = cbEmptyLines.Checked;
                    textExport.Frames     = cbbFrames.SelectedIndex != 0;
                    textExport.TextFrames = cbbFrames.SelectedIndex == 1;
                    textExport.DataOnly   = cbDataOnly.Checked;
                    if (cbbCodepage.SelectedIndex == 0)
                    {
                        textExport.Encoding = Encoding.Default;
                    }
                    else if (cbbCodepage.SelectedIndex == 2)
                    {
                        textExport.Encoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage);
                    }
                    textExport.ScaleX           = (float)udX.Value;
                    textExport.ScaleY           = (float)udY.Value;
                    textExport.PrintAfterExport = true;
                    textExport.OpenAfterExport  = false;
                    textExport.AvoidDataLoss    = false;
                    using (MemoryStream memStream = new MemoryStream())
                        textExport.Export(report, memStream);
                }
            }
        }
Example #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TextExport parentExport = Export as TextExport;
            TextExport textExport   = new TextExport();

            textExport.PageBreaks = cbPageBreaks.Checked;
            textExport.EmptyLines = cbEmptyLines.Checked;
            textExport.Frames     = cbbFrames.SelectedIndex != 0;
            textExport.TextFrames = cbbFrames.SelectedIndex == 1;
            textExport.DataOnly   = cbDataOnly.Checked;
            if (cbbCodepage.SelectedIndex == 0)
            {
                textExport.Encoding = Encoding.Default;
            }
            else if (cbbCodepage.SelectedIndex == 1)
            {
                textExport.Encoding = Encoding.UTF8;
            }
            else if (cbbCodepage.SelectedIndex == 2)
            {
                textExport.Encoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage);
            }
            textExport.ScaleX          = (float)udX.Value;
            textExport.ScaleY          = (float)udY.Value;
            textExport.OpenAfterExport = false;
            textExport.AvoidDataLoss   = false;
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.FileName = Path.GetFileNameWithoutExtension(Path.GetFileName(report.FileName));
                dialog.Filter   = textExport.FileFilter;
                string defaultExt = dialog.Filter.Split(new char[] { '|' })[1];
                dialog.DefaultExt = Path.GetExtension(defaultExt);
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Application.DoEvents();
                    textExport.Export(report, dialog.FileName);
                }
            }
        }
Example #9
0
        private void TextExportForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            TextExport textExport = Export as TextExport;

            textExport.PageBreaks = cbPageBreaks.Checked;
            textExport.EmptyLines = cbEmptyLines.Checked;
            textExport.Frames     = cbbFrames.SelectedIndex != 0;
            textExport.TextFrames = cbbFrames.SelectedIndex == 1;
            textExport.DataOnly   = cbDataOnly.Checked;
            if (cbbCodepage.SelectedIndex == 0)
            {
                textExport.Encoding = Encoding.Default;
            }
            else if (cbbCodepage.SelectedIndex == 1)
            {
                textExport.Encoding = Encoding.UTF8;
            }
            else if (cbbCodepage.SelectedIndex == 2)
            {
                textExport.Encoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage);
            }
            textExport.ScaleX = (float)udX.Value;
            textExport.ScaleY = (float)udY.Value;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;
            // select export format type
            switch (identificator)
            {
                case EXPORT_EXTENSION_HTM:
                case EXPORT_TYPE_NAME_HTM:
                    export = new HtmlExport();
                    break;

                case EXPORT_EXTENSION_PDF:
                case EXPORT_TYPE_NAME_PDF:
                    export = new PdfExport();
                    break;

                case EXPORT_EXTENSION_RTF:
                case EXPORT_TYPE_NAME_RTF:
                    export = new RtfExport();
                    break;

                case EXPORT_EXTENSION_TIF:
                case EXPORT_TYPE_NAME_TIF:
                    export = new TiffExport();
                    break;

                case EXPORT_EXTENSION_TXT:
                case EXPORT_TYPE_NAME_TXT:
                    export = new TextExport();
                    break;

                case EXPORT_EXTENSION_XLS:
                case EXPORT_TYPE_NAME_XLS:
                    export = new XlsExport();
                    break;

                default:
                    Debug.Assert(false); // NOTE: not supported
                    break;
            }

            return export;
        }