Esempio n. 1
0
        public void SaveAs(string FileName, fyiReporting.RDL.OutputPresentationType type)
        {
            fyiReporting.RDL.OneFileStreamGen sg = null;

            try
            {
                // Must use the RunGetData before each export or there is no data.
                _report.RunGetData(this.Parameters);

                sg = new fyiReporting.RDL.OneFileStreamGen(FileName, true);
                _report.RunRender(sg, type);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex.Message);
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }
            }
            return;
        }
Esempio n. 2
0
        public bool Export(fyiReporting.RDL.OutputPresentationType type)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title = "Export to " + type.ToString().ToUpper();
            switch (type)
            {
            case  OutputPresentationType.CSV:
                sfd.Filter = "CSV file (*.csv)|*.csv|All files (*.*)|*.*";
                break;

            case OutputPresentationType.XML:
                sfd.Filter = "XML file (*.xml)|*.xml|All files (*.*)|*.*";
                break;

            case OutputPresentationType.PDF:
            case OutputPresentationType.PDFOldStyle:
                sfd.Filter = "PDF file (*.pdf)|*.pdf|All files (*.*)|*.*";
                break;

            case OutputPresentationType.TIF:
                sfd.Filter = "TIF file (*.tif, *.tiff)|*.tiff;*.tif|All files (*.*)|*.*";
                break;

            case OutputPresentationType.RTF:
                sfd.Filter = "RTF file (*.rtf)|*.rtf|All files (*.*)|*.*";
                break;

            case OutputPresentationType.Word:
                sfd.Filter = "DOC file (*.doc)|*.doc|All files (*.*)|*.*";
                break;

            case OutputPresentationType.Excel:
                sfd.Filter = "Excel file (*.xlsx)|*.xlsx|All files (*.*)|*.*";
                break;

            case OutputPresentationType.HTML:
                sfd.Filter = "Web Page (*.html, *.htm)|*.html;*.htm|All files (*.*)|*.*";
                break;

            case OutputPresentationType.MHTML:
                sfd.Filter = "MHT (*.mht)|*.mhtml;*.mht|All files (*.*)|*.*";
                break;

            default:
                throw new Exception("Only HTML, MHT, XML, CSV, RTF, DOC, Excel, TIF and PDF are allowed as Export types.");
            }
            sfd.FilterIndex = 1;

            if (SourceFile != null)
            {
                sfd.FileName = Path.GetFileNameWithoutExtension(SourceFile.LocalPath) + "." + type;
            }
            else
            {
                sfd.FileName = "*." + type;
            }

            try
            {
                if (sfd.ShowDialog(this) != DialogResult.OK)
                {
                    return(false);
                }

                // save the report in the requested rendered format
                bool rc = true;
                // tif can be either in color or black and white; ask user what they want
                if (type == OutputPresentationType.TIF)
                {
                    DialogResult dr = MessageBox.Show(this, "Do you want to display colors in TIF?", "Export", MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.No)
                    {
                        type = OutputPresentationType.TIFBW;
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                try { SaveAs(sfd.FileName, type); }
                catch (Exception ex)
                {
                    MessageBox.Show(this,
                                    ex.Message, "Export Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    rc = false;
                }
                return(rc);
            }
            finally
            {
                sfd.Dispose();
            }
        }
Esempio n. 3
0
        public bool Export(fyiReporting.RDL.OutputPresentationType type)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title = string.Format(Strings.MDIChild_Export_ExportTitleFormat, type.ToString().ToUpper());
            switch (type)
            {
            case OutputPresentationType.CSV:
                sfd.Filter = Strings.MDIChild_Export_CSV;
                break;

            case OutputPresentationType.XML:
                sfd.Filter = Strings.MDIChild_Export_XML;
                break;

            case OutputPresentationType.PDF:
            case OutputPresentationType.PDFOldStyle:
                sfd.Filter = Strings.MDIChild_Export_PDF;
                break;

            case OutputPresentationType.TIF:
                sfd.Filter = Strings.MDIChild_Export_TIF;
                break;

            case OutputPresentationType.RTF:
                sfd.Filter = Strings.MDIChild_Export_RTF;
                break;

            case OutputPresentationType.Word:
                sfd.Filter = Strings.MDIChild_Export_DOC;
                break;

            case OutputPresentationType.ExcelTableOnly:
                sfd.Filter = Strings.MDIChild_Export_Excel;
                break;

            case OutputPresentationType.HTML:
                sfd.Filter = Strings.MDIChild_Export_Web_Page;
                break;

            case OutputPresentationType.MHTML:
                sfd.Filter = Strings.MDIChild_Export_MHT;
                break;

            default:
                throw new Exception(Strings.MDIChild_Error_AllowedExportTypes);
            }
            sfd.FilterIndex = 1;

            if (SourceFile != null)
            {
                sfd.FileName = Path.GetFileNameWithoutExtension(SourceFile.LocalPath) + "." + type;
            }
            else
            {
                sfd.FileName = "*." + type;
            }

            try
            {
                if (sfd.ShowDialog(this) != DialogResult.OK)
                {
                    return(false);
                }

                // save the report in the requested rendered format
                bool rc = true;
                // tif can be either in color or black and white; ask user what they want
                if (type == OutputPresentationType.TIF)
                {
                    DialogResult dr = MessageBox.Show(this, Strings.MDIChild_ShowF_WantDisplayColorsInTIF, Strings.MDIChild_ShowF_Export, MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.No)
                    {
                        type = OutputPresentationType.TIFBW;
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                try { SaveAs(sfd.FileName, type); }
                catch (Exception ex)
                {
                    MessageBox.Show(this,
                                    ex.Message, Strings.MDIChild_ShowG_ExportError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    rc = false;
                }
                return(rc);
            }
            finally
            {
                sfd.Dispose();
            }
        }
Esempio n. 4
0
        public void SaveAs()
        {
            SaveFileDialog dlg = new SaveFileDialog("Select a file");

            dlg.Multiselect = false;
            dlg.Filters.Add(new FileDialogFilter("PDF files", "*.pdf"));
            dlg.Filters.Add(new FileDialogFilter("XML files", "*.xml"));
            dlg.Filters.Add(new FileDialogFilter("HTML files", "*.html"));
            dlg.Filters.Add(new FileDialogFilter("CSV files", "*.csv"));
            dlg.Filters.Add(new FileDialogFilter("RTF files", "*.rtf"));
            dlg.Filters.Add(new FileDialogFilter("TIF files", "*.tif"));
            dlg.Filters.Add(new FileDialogFilter("Excel files", "*.xlsx"));
            dlg.Filters.Add(new FileDialogFilter("MHT files", "*.mht"));


            Uri file = this.SourceFile;

            if (file != null)
            {
                dlg.InitialFileName = "*.pdf";
            }
            else
            {
                dlg.InitialFileName = "*.pdf";
            }



            if (dlg.Run() == false)
            {
                return;
            }

            // save the report in a rendered format
            string ext = null;
            int    i   = dlg.FileName.LastIndexOf('.');

            if (i < 1)
            {
                ext = "";
            }
            else
            {
                ext = dlg.FileName.Substring(i + 1).ToLower();
            }

            fyiReporting.RDL.OutputPresentationType type = fyiReporting.RDL.OutputPresentationType.Internal;
            switch (ext)
            {
            case "pdf":
                type = fyiReporting.RDL.OutputPresentationType.PDF;
                break;

            case "xml":
                type = fyiReporting.RDL.OutputPresentationType.XML;
                break;

            case "html":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "htm":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "csv":
                type = fyiReporting.RDL.OutputPresentationType.CSV;
                break;

            case "rtf":
                type = fyiReporting.RDL.OutputPresentationType.RTF;
                break;

            case "mht":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "mhtml":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "xlsx":
                type = fyiReporting.RDL.OutputPresentationType.Excel;
                break;

            case "tif":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            case "tiff":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            default:
                MessageDialog.ShowMessage(String.Format("{0} is not a valid file type.  File extension must be PDF, XML, HTML, CSV, MHT, RTF, TIF, XLSX.", dlg.FileName));
                break;
            }


            SaveAs(dlg.FileName, type);
        }
        private void SaveAsClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            var dlg = new SaveFileDialog();

            dlg.Filter   = Strings.RdlViewer_menuFileSaveAs_Click_FilesFilter;
            dlg.FileName = ".pdf";
            var result = dlg.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            // save the report in a rendered format
            string ext = null;
            int    i   = dlg.FileName.LastIndexOf('.');

            if (i < 1)
            {
                ext = "";
            }
            else
            {
                ext = dlg.FileName.Substring(i + 1).ToLower();
            }
            fyiReporting.RDL.OutputPresentationType type = fyiReporting.RDL.OutputPresentationType.Internal;
            switch (ext)
            {
            case "pdf":
                type = fyiReporting.RDL.OutputPresentationType.PDF;
                break;

            case "xml":
                type = fyiReporting.RDL.OutputPresentationType.XML;
                break;

            case "html":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "htm":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "csv":
                type = fyiReporting.RDL.OutputPresentationType.CSV;
                break;

            case "rtf":
                type = fyiReporting.RDL.OutputPresentationType.RTF;
                break;

            case "mht":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "mhtml":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "xlsx":
                type = dlg.FilterIndex == 7 ? OutputPresentationType.ExcelTableOnly : OutputPresentationType.Excel2007;
                break;

            case "tif":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            case "tiff":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            default:
                MessageBox.Show(String.Format("{0} is not a valid file type. File extension must be PDF, XML, HTML, CSV, MHT, RTF, TIF, XLSX.", dlg.FileName),
                                "Invalid File Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            Viewer.SaveAs(dlg.FileName, type);
        }
        private void SaveAsClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            var dlg = new SaveFileDialog();

            dlg.Filter   = "PDF files|*.pdf|XML files|*.xml|HTML files|*.html|CSV files|*.csv|RTF files|*.rtf|TIF files|*.tif|Excel files|*.xlsx|MHT files|*.mht|DMP files|*.dmp";
            dlg.FileName = ".pdf";
            var result = dlg.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            // save the report in a rendered format
            string ext = null;
            int    i   = dlg.FileName.LastIndexOf('.');

            if (i < 1)
            {
                ext = "";
            }
            else
            {
                ext = dlg.FileName.Substring(i + 1).ToLower();
            }
            fyiReporting.RDL.OutputPresentationType type = fyiReporting.RDL.OutputPresentationType.Internal;
            switch (ext)
            {
            case "pdf":
                type = fyiReporting.RDL.OutputPresentationType.PDF;
                break;

            case "xml":
                type = fyiReporting.RDL.OutputPresentationType.XML;
                break;

            case "html":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "htm":
                type = fyiReporting.RDL.OutputPresentationType.HTML;
                break;

            case "dmp":
                type = fyiReporting.RDL.OutputPresentationType.DMP;
                break;

            case "csv":
                type = fyiReporting.RDL.OutputPresentationType.CSV;
                break;

            case "rtf":
                type = fyiReporting.RDL.OutputPresentationType.RTF;
                break;

            case "mht":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "mhtml":
                type = fyiReporting.RDL.OutputPresentationType.MHTML;
                break;

            case "xlsx":
                type = fyiReporting.RDL.OutputPresentationType.Excel;
                break;

            case "tif":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            case "tiff":
                type = fyiReporting.RDL.OutputPresentationType.TIF;
                break;

            default:
                MessageBox.Show(String.Format("{0} is not a valid file type. File extension must be PDF, XML, HTML, CSV, MHT, RTF, TIF, XLSX, DMP.", dlg.FileName),
                                "Invalid File Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            Viewer.SaveAs(dlg.FileName, type);
        }