/// <summary>
 /// Creates a text report for the plot model.
 /// </summary>
 /// <param name="plotModel">The plot model.</param>
 /// <returns>A text report that contains information about the contents of the plot model.</returns>
 public static string CreateTextReport(this PlotModel plotModel)
 {
     using (var ms = new MemoryStream())
     {
         var    trw    = new TextReportWriter(ms);
         Report report = plotModel.CreateReport();
         report.Write(trw);
         trw.Flush();
         ms.Position = 0;
         var r = new StreamReader(ms);
         return(r.ReadToEnd());
     }
 }
 /// <summary>
 /// Creates a text report for the plot model.
 /// </summary>
 /// <param name="plotModel">The plot model.</param>
 /// <returns>A text report that contains information about the contents of the plot model.</returns>
 public static string CreateTextReport(this PlotModel plotModel)
 {
     using (var ms = new MemoryStream())
     {
         var trw = new TextReportWriter(ms);
         Report report = plotModel.CreateReport();
         report.Write(trw);
         trw.Flush();
         ms.Position = 0;
         var r = new StreamReader(ms);
         return r.ReadToEnd();
     }
 }
Example #3
0
        public void SaveReport(string fileName)
        {
            string ext = Path.GetExtension(fileName);
            if (ext == null)
            {
                return;
            }

            ext = ext.ToLower();

            var r = this.CreateReport(fileName);
            var reportStyle = new ReportStyle();

            switch (ext)
            {
                case ".txt":
                    using (var s = File.Create(fileName))
                    {
                        using (var w = new TextReportWriter(s))
                        {
                            r.Write(w);
                        }
                    }

                    break;

                case ".html":
                    using (var s = File.Create(fileName))
                    {
                        using (var w = new HtmlReportWriter(s))
                        {
                            w.WriteReport(r, reportStyle);
                        }
                    }

                    break;

                case ".pdf":
                    using (var w = new PdfReportWriter(fileName))
                    {
                        w.WriteReport(r, reportStyle);
                    }

                    break;

                case ".rtf":
                    using (var w = new RtfReportWriter(fileName))
                    {
                        w.WriteReport(r, reportStyle);
                    }

                    break;

                case ".tex":
                    using (var s = File.Create(fileName))
                    {
                        using (var w = new LatexReportWriter(s, "Example report", "oxyplot"))
                        {
                            w.WriteReport(r, reportStyle);
                        }
                    }

                    break;

                case ".xps":
                    using (var w = new FlowDocumentReportWriter())
                    {
                        w.WriteReport(r, reportStyle);
                        w.Save(fileName);
                    }

                    break;
                case ".docx":
                    using (var w = new WordDocumentReportWriter(fileName))
                    {
                        w.WriteReport(r, reportStyle);
                        w.Save();
                    }

                    break;
            }
        }