public void Build() { using (WordprocessingDocument wordDocument = WordprocessingDocument.Create("sample.docx", WordprocessingDocumentType.Document)) { wordDocument.Initialize(); MainDocumentPart mainPart = wordDocument.MainDocumentPart; Body body = mainPart.Document.Body; var summaries = new Dictionary<Module, List<Dictionary<Tuple<Expertise, Priority>, decimal>>>(); for (int i = 0; i < this._modules.Module.Length; i++) { var module = this._modules.Module[i]; summaries.Add(module, new List<Dictionary<Tuple<Expertise, Priority>, decimal>>()); FormatTitle(body, module); TableHelpers.AddTable( wordDocument, new[,] { { "Status", "Version", "Priority", "License" }, { module.Status.ToString(), module.Version, module.Priority.ToString(), module.License.ToString() } }); body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Technologies")); TableHelpers.AddTable(wordDocument, this.BuildTechnologyList(module.Technologies)); body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Overview")); body.AppendChild(new Paragraph()).AppendChild(new Run()).AppendChild(new Text(module.Overview)); body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Dependencies")); body.AppendChild(new Paragraph().AppendText("This module has dependencies on")); foreach (var dep in module.Dependencies) { var paragraph = new Paragraph().AsBulletedList(0, 1); paragraph.AppendText(dep); body.AppendChild(paragraph); } body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Work Remaining")); TableHelpers.AddTable( wordDocument, this.BuildFeaturesList(module.Features)); var summary = new Dictionary<Tuple<Expertise, Priority>, decimal>(); body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Pricing Matrix")); TableHelpers.AddTable( wordDocument, this.BuildPricingMatrix(module, ref summary)); summaries[module].Add(summary); body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Totals")); TableHelpers.AddTable( wordDocument, CalculateSummaryValues(summary, module)); body.AppendChild(new Paragraph(new Run(new Break { Type = BreakValues.Page }))); } body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading2.Id).AppendText("Summary")); TableHelpers.AddTable(wordDocument, this.CalculateTotalSummaries(summaries)); } }