public void SaveAs(string FileName, fyiReporting.RDL.OutputPresentationType type)
 {
     this.reportViewer.SaveAs(FileName, type);
 }
Exemplo n.º 2
0
        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";
            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 = 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.", dlg.FileName),
                                "Invalid File Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

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