/// <summary> /// Creates the css section. /// </summary> /// <param name="style"> /// The style. /// </param> /// <returns> /// The css. /// </returns> private static string CreateCss(ReportStyle style) { var css = new StringBuilder(); css.AppendLine("body { " + ParagraphStyleToCss(style.BodyTextStyle) + " }"); for (int i = 0; i < style.HeaderStyles.Length; i++) { css.AppendLine("h" + (i + 1) + " {" + ParagraphStyleToCss(style.HeaderStyles[i]) + " }"); } css.AppendLine("table caption { " + ParagraphStyleToCss(style.TableCaptionStyle) + " }"); css.AppendLine("thead { " + ParagraphStyleToCss(style.TableHeaderStyle) + " }"); css.AppendLine("td { " + ParagraphStyleToCss(style.TableTextStyle) + " }"); css.AppendLine("td.header { " + ParagraphStyleToCss(style.TableHeaderStyle) + " }"); css.AppendLine("figuretext { " + ParagraphStyleToCss(style.FigureTextStyle) + " }"); css.Append( @"body { margin:20pt; } table { border: solid 1px black; margin: 8pt; border-collapse:collapse; } td { padding: 0 2pt 0 2pt; border-left: solid 1px black; border-right: solid 1px black;} thead { border:solid 1px black; } .content, .content td { border: none; } .figure { margin: 8pt;} .table { margin: 8pt;} .table caption { margin: 4pt;} .table thead td { padding: 2pt;}"); return(css.ToString()); }
/// <summary> /// Creates the css section. /// </summary> /// <param name="style"> /// The style. /// </param> /// <returns> /// The css. /// </returns> private static string CreateCss(ReportStyle style) { var css = new StringBuilder(); css.AppendLine("body { " + ParagraphStyleToCss(style.BodyTextStyle) + " }"); for (int i = 0; i < style.HeaderStyles.Length; i++) { css.AppendLine("h" + (i + 1) + " {" + ParagraphStyleToCss(style.HeaderStyles[i]) + " }"); } css.AppendLine("table caption { " + ParagraphStyleToCss(style.TableCaptionStyle) + " }"); css.AppendLine("thead { " + ParagraphStyleToCss(style.TableHeaderStyle) + " }"); css.AppendLine("td { " + ParagraphStyleToCss(style.TableTextStyle) + " }"); css.AppendLine("td.header { " + ParagraphStyleToCss(style.TableHeaderStyle) + " }"); css.AppendLine("figuretext { " + ParagraphStyleToCss(style.FigureTextStyle) + " }"); css.Append( @"body { margin:20pt; } table { border: solid 1px black; margin: 8pt; border-collapse:collapse; } td { padding: 0 2pt 0 2pt; border-left: solid 1px black; border-right: solid 1px black;} thead { border:solid 1px black; } .content, .content td { border: none; } .figure { margin: 8pt;} .table { margin: 8pt;} .table caption { margin: 4pt;} .table thead td { padding: 2pt;}"); return css.ToString(); }
/// <summary> /// The write report. /// </summary> /// <param name="report"> /// The report. /// </param> /// <param name="reportStyle"> /// The style. /// </param> public void WriteReport(Report report, ReportStyle reportStyle) { this.style = reportStyle; this.WriteHtmlHeader(report.Title, null, CreateCss(reportStyle)); report.Write(this); }
/// <summary> /// The write report. /// </summary> /// <param name="report">The report.</param> /// <param name="reportStyle">The style.</param> public void WriteReport(Report report, ReportStyle reportStyle) { report.Write(this); }
/// <summary> /// The add styles. /// </summary> /// <param name="sdp"> /// The sdp. /// </param> /// <param name="style"> /// The style. /// </param> private void AddStyles(StyleDefinitionsPart sdp, ReportStyle style) { sdp.Styles = new Styles(); sdp.Styles.Append(CreateStyle(style.BodyTextStyle, BodyTextID, BodyTextName, null, null, true, false)); for (int i = 0; i < style.HeaderStyles.Length; i++) { sdp.Styles.Append( CreateStyle( style.HeaderStyles[i], string.Format(HeaderID, i + 1), string.Format(HeaderName, i + 1), "Heading1", BodyTextID, false, false)); } sdp.Styles.Append(CreateStyle(style.TableTextStyle, TableTextID, TableTextName, null, null)); sdp.Styles.Append(CreateStyle(style.TableHeaderStyle, TableHeaderID, TableHeaderName, null, null)); sdp.Styles.Append(CreateStyle(style.TableCaptionStyle, TableCaptionID, TableCaptionName, null, null)); sdp.Styles.Append(CreateStyle(style.FigureTextStyle, FigureTextID, FigureTextName, null, null)); }
/// <summary> /// The write report. /// </summary> /// <param name="report"> /// The report. /// </param> /// <param name="reportStyle"> /// The style. /// </param> public void WriteReport(Report report, ReportStyle reportStyle) { this.style = reportStyle; this.AddStyles(this.stylePart, reportStyle); report.Write(this); }
/// <summary> /// The write report. /// </summary> /// <param name="report"> /// The report. /// </param> /// <param name="reportStyle"> /// The style. /// </param> public void WriteReport(Report report, ReportStyle reportStyle) { this.Style = reportStyle; report.Write(this); }
/// <summary> /// Writes the report. /// </summary> /// <param name="report"> /// The report. /// </param> /// <param name="reportStyle"> /// The style. /// </param> public void WriteReport(Report report, ReportStyle reportStyle) { report.Write(this); }
/// <summary> /// The write report. /// </summary> /// <param name="report"> /// The report. /// </param> /// <param name="reportStyle"> /// The style. /// </param> public void WriteReport(Report report, ReportStyle reportStyle) { this.style = reportStyle; this.WriteHtmlHeader(report.Title, null, CreateCss(reportStyle)); report.Write(this); }
/// <summary> /// Defines the styles used in the document. /// </summary> /// <param name="document">The document.</param> /// <param name="reportStyle">The report Style.</param> public static void DefineStyles(Document document, ReportStyle reportStyle) { SetStyle(document.Styles["Normal"], reportStyle.BodyTextStyle); // Heading1 to Heading9 are predefined styles with an outline level. An outline level // other than OutlineLevel.BodyText automatically creates the outline (or bookmarks) // in PDF. for (int i = 0; i < reportStyle.HeaderStyles.Length; i++) { SetStyle(document.Styles["Heading" + (i + 1)], reportStyle.HeaderStyles[i]); } // style = document.Styles[StyleNames.Header]; // style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right); // style = document.Styles[StyleNames.Footer]; // style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center); var style = document.Styles.AddStyle("TableHeader", "Normal"); SetStyle(style, reportStyle.TableHeaderStyle); style = document.Styles.AddStyle("TableCaption", "Normal"); SetStyle(style, reportStyle.TableCaptionStyle); style = document.Styles.AddStyle("TableText", "Normal"); SetStyle(style, reportStyle.TableTextStyle); style = document.Styles.AddStyle("FigureText", "Normal"); SetStyle(style, reportStyle.FigureTextStyle); }
/// <summary> /// Writes the specified report. /// </summary> /// <param name="report">The report.</param> /// <param name="reportStyle">The report style.</param> public void WriteReport(Report report, ReportStyle reportStyle) { this.style = reportStyle; DefineStyles(this.Document, reportStyle); report.Write(this); }
/// <summary> /// Gets the full caption. /// </summary> /// <param name="style">The style.</param> /// <returns>The caption string.</returns> public string GetFullCaption(ReportStyle style) { return(string.Format(style.TableCaptionFormatString, this.TableNumber, this.Caption)); }
/// <summary> /// Gets the full caption. /// </summary> /// <param name="style">The style.</param> /// <returns>The caption string.</returns> public string GetFullCaption(ReportStyle style) { return string.Format(style.TableCaptionFormatString, this.TableNumber, this.Caption); }
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; } }