static void Main(string[] args) { var pm = new PlotModel { Title = "Test" }; pm.Axes.Add(new LinearAxis { Title = "Bottom", Position = AxisPosition.Bottom, AxisTitleDistance = 10 }); pm.Axes.Add(new LinearAxis { Title = "Left", Position = AxisPosition.Left }); pm.Series.Add(new FunctionSeries(Math.Sin, 0, 10, 0.01)); var e = new PdfExporter(); e.Width = 800; e.Height = 500; e.Background = OxyColors.LightBlue; var path = "test.docx"; var r = new Report(); r.AddPlot(pm, "Plot test", 800, 500); var rs = new ReportStyle(); Action export = () => { using (var w = new WordDocumentReportWriter(path)) { w.WriteReport(r, rs); w.Save(); } }; var thread = new Thread(new ThreadStart(export)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); // Process.Start(path); }
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; } }