public override void AppendList <T>(IEnumerable <T> items, Style style) { if (items == null || !items.Any()) { return; } _report.Add(TableElement.Create(items, style)); }
public override void AppendDictionary <T1, T2>(IDictionary <T1, T2> records, Style style) { if (records == null || !records.Any()) { return; } _report.Add(TableElement.Create(records, style)); }
public void ConstructorSeparatesPartsOfTheName() { Document doc = new Document(); var slide = new SlideElement(doc); TableElement element = TableElement.Create(@"TEST_1[""column 1"", 4, 6][2, 4, ""row 1""] FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""'column 2' - 'column 1'""}", null, slide); Assert.AreEqual(@"TEST_1[""column 1"", 4, 6][2, 4, ""row 1""] FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""'column 2' - 'column 1'""}", element.FullName); Assert.AreEqual("TEST_1", element.Name); Assert.AreEqual(@"""column 1"", 4, 6", element.DataDescriptor.ColumnIndexesString); Assert.AreEqual(@"2, 4, ""row 1""", element.DataDescriptor.RowIndexesString); Assert.AreEqual(@"FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""'column 2' - 'column 1'""}", element.CommandString); }
public virtual void DiscoverShapes() { var shapes = Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:")); Shapes.AddRange(shapes.Select(s => ShapeElement.Create(s.ElementName().Substring(5).Trim(), s, this)).Where(s => s != null)); var graphicFrames = Slide.Descendants <DocumentFormat.OpenXml.Presentation.GraphicFrame>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:")); foreach (var item in graphicFrames) { string name = item.ElementName().Substring(5).Trim(); if (item.Graphic.GraphicData.FirstElement <Table>() != null) { TableElement table = TableElement.Create(name, item, this); if (table != null) { Shapes.Add(table); } } else if (item.Graphic.GraphicData.FirstElement <ChartReference>() != null) { ChartElement chart = ChartElement.Create(name, item, this); if (chart != null) { Shapes.Add(chart); } } } var paragraphs = Slide.Descendants <Paragraph>(); foreach (var item in paragraphs) { if (!item.Ancestors <Table>().Any()) { if (textTagRegex.Match(item.InnerText).Success) { foreach (Match match in textTagRegex.Matches(item.InnerText)) { McKinsey.PowerPointGenerator.Elements.TextElement text = McKinsey.PowerPointGenerator.Elements.TextElement.Create(match.Groups["tag"].Value, item, this); if (text != null) { Shapes.Add(text); } } } } } foreach (ShapeElementBase item in Shapes) { item.Slide = this; } }
public void PreprocessSwitchCommandsSetsDefaultValuesWhenNoSwitchCommandsExist() { Document doc = new Document(); var slide = new SlideElement(doc); TableElement element = TableElement.Create("TEST", null, slide); var commands = new List <Command>() { new FormatCommand(), new FormulaCommand(), new NoContentCommand() }; var result = element.PreprocessSwitchCommands(commands); Assert.AreEqual(3, result.Count()); Assert.IsFalse(element.IsFixed); Assert.IsFalse(element.IsPaged); }
public void PreprocessSwitchCommandsGetAllCommandsIfTheyExist() { Document doc = new Document(); var slide = new SlideElement(doc); TableElement element = TableElement.Create("TEST", null, slide); var commands = new List <Command>() { new FormatCommand(), new FormulaCommand(), new NoContentCommand(), new FixedCommand(), new WaterfallCommand(), new PageCommand() }; var result = element.PreprocessSwitchCommands(commands); Assert.AreEqual(5, result.Count()); Assert.IsTrue(element.IsFixed); Assert.IsTrue(element.IsPaged); }