public void CreateReport(MainDocumentPart mainPart, Report report) { TextContent tc = new TextContent(); tc.GenerateTextContent(mainPart, report.Client, contentSourceXml); ChartItem chartItem = null; string controlName = null; // Model Table Table table = report.ModelTable(); controlName = "ModelTable"; AddTableToDoc(mainPart, table, controlName); // Drawdown chartItem = report.Drawdown(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Comparison Chart if (report.Client.ExistingAssets) { chartItem = report.AllocationComparison(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); } // Stress Test Market Rise Bar Chart chartItem = report.StressTestMarketRise(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Stress Test Market Crash Bar Chart chartItem = report.StressTestMarketCrash(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Allocation Pie Chart chartItem = report.Allocation(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Rolling Return 1 yr chartItem = report.RollingReturnChart(1); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Rolling Return 3 yr chartItem = report.RollingReturnChart(3); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Rolling Return 5 yr chartItem = report.RollingReturnChart(5); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // Ten Year Return Chart chartItem = report.TenYearReturn(); controlName = chartItem.CustomControlName; AddChartToDoc(mainPart, chartItem, controlName); // save and close document mainPart.Document.Save(); }
public string CreateReport() { // check client assets; throw error on failure Report.Client.ValidateClientAssets(); string tempDocName = null; WordprocessingDocument myWordDoc = null; MainDocumentPart mainPart = null; MemoryStream tempXmlStream = null; try { // create temp files/streams tempDocName = createTempDocFile(TemplateFile, TempDir); tempXmlStream = createTempXmlStream(ContentXmlFile); // open Word document myWordDoc = WordprocessingDocument.Open(tempDocName, true); mainPart = myWordDoc.MainDocumentPart; // Add text content TextContent tc = new TextContent(Report); tc.GenerateTextContent(mainPart, ContentXmlFile, tempXmlStream, FillContentControls); // Model Table string controlName = null; Table table = Report.ModelTable(); controlName = "ModelTable"; AddTableToDoc(mainPart, table, controlName); // Charts AddChartsToDoc(mainPart, Report); } finally { // save and close document if (tempXmlStream != null) tempXmlStream.Close(); if (mainPart != null) mainPart.Document.Save(); if (myWordDoc != null) myWordDoc.Close(); if (tempXmlStream != null) tempXmlStream.Close(); } return tempDocName; }