using System.Globalization; using System.Net; using OfficeIMO.Drawing; using OfficeIMO.Html; using OfficeIMO.Html.Pdf; namespace OfficeIMO.Examples.Showcase.Workflows; /// Builds an HTML service review from measured and target values, including explicit misses. internal static class ServiceLevelReport { internal static void Create(string folder) { var measures = new[] { new Measure("Availability", 99.94m, 99.90m, "%", true), new Measure("First response", 3.2m, 4m, "hours", false), new Measure("Resolution within target", 88m, 90m, "%", true) }; string rows = string.Join("", measures.Select(measure => { bool met = measure.HigherIsBetter ? measure.Actual >= measure.Target : measure.Actual <= measure.Target; return $"{WebUtility.HtmlEncode(measure.Name)}{measure.Actual.ToString("0.##", CultureInfo.InvariantCulture)} {measure.Unit}{measure.Target.ToString("0.##", CultureInfo.InvariantCulture)} {measure.Unit}{(met ? "Met" : "Below target")}"; })); string html = $$""" Monthly service review

NORTHWIND / SERVICE OPERATIONS

Monthly service review

August 2026 / request portal / illustrative measurements

Performance against agreed targets

{{rows}}
MeasureActualTargetResult
Attention required

Resolution within target missed the agreed threshold. Review the oldest waiting requests and assign an owner to each next action.

Follow-up actions

  1. Separate customer waiting time from internal queue time.
  2. Review the ten oldest requests with the service owner.
  3. Recheck the measure after two weeks of targeted follow-up.

Measurement notes

Availability uses the agreed service window. First response is the median elapsed time. Resolution reports the share completed within the agreed target. Replace these definitions with the actual service contract.

"""; File.WriteAllText(Path.Combine(folder, "example.html"), html); HtmlConversionDocument.Parse(html).SaveAsPdf(Path.Combine(folder, "preview.pdf"), new HtmlToPdfOptions { PageSize = OfficePageSizes.A4, Margins = HtmlRenderMargins.All(24D) }).RequireSuccess(); } private sealed record Measure(string Name, decimal Actual, decimal Target, string Unit, bool HigherIsBetter); }