public static void Run() { //ExStart:SetAutofitOftextframe // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create an instance of Presentation class Presentation presentation = new Presentation(); // Access the first slide ISlide slide = presentation.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350); // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); ashp.FillFormat.FillType = FillType.NoFill; // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; txtFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog."; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; // Save Presentation presentation.Save(dataDir + "formatText_out.pptx", SaveFormat.Pptx); }
private static IPortion GetPortion(SCPresentation presentation) { IAutoShape autoShape = presentation.Slides[0].Shapes.First(sp => sp.Id == 4) as IAutoShape; IPortion portion = autoShape.TextBox.Paragraphs[0].Portions[0]; return(portion); }
public void Size_Getter_ReturnsFontSize_OfNonPlaceholderTable() { // Arrange ITable table = (ITable)_fixture.Pre009.Slides[2].Shapes.First(sp => sp.Id == 3); IPortion cellPortion = table.Rows[0].Cells[0].TextBox.Paragraphs[0].Portions[0]; // Act-Assert cellPortion.Font.Size.Should().Be(1800); }
public void IsItalic_GetterReturnsTrue_WhenFontOfPlaceholderTextIsItalic() { // Arrange IAutoShape placeholderAutoShape = (IAutoShape)_fixture.Pre020.Slides[2].Shapes.First(sp => sp.Id == 7); IPortion portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0]; // Act-Assert portion.Font.IsItalic.Should().BeTrue(); }
public static void Run() { // ExStart:FontFamily // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate Presentation Class using (Presentation pres = new Presentation()) { // Get first slide ISlide sld = pres.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 200, 50); // Remove any fill style associated with the AutoShape ashp.FillFormat.FillType = FillType.NoFill; // Access the TextFrame associated with the AutoShape ITextFrame tf = ashp.TextFrame; tf.Text = "Aspose TextBox"; // Access the Portion associated with the TextFrame IPortion port = tf.Paragraphs[0].Portions[0]; // Set the Font for the Portion port.PortionFormat.LatinFont = new FontData("Times New Roman"); // Set Bold property of the Font port.PortionFormat.FontBold = NullableBool.True; // Set Italic property of the Font port.PortionFormat.FontItalic = NullableBool.True; // Set Underline property of the Font port.PortionFormat.FontUnderline = TextUnderlineType.Single; // Set the Height of the Font port.PortionFormat.FontHeight = 25; // Set the color of the Font port.PortionFormat.FillFormat.FillType = FillType.Solid; port.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; //Write the presentation to disk pres.Save(dataDir + "pptxFont_out.pptx", SaveFormat.Pptx); } // ExEnd:FontFamily }
/// <inheritdoc/> public void Remove(IPortion removingPortion) { Portion removingInnerPortion = (Portion)removingPortion; removingInnerPortion.AText.Parent.Remove(); // remove parent <a:r> removingInnerPortion.IsRemoved = true; this.portions.Reset(); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Instantiate PresentationEx using (Presentation presentation = new Presentation(dataDir + "DefaultFonts.pptx")) { // ExStart:ManagParagraphFontProperties // Accessing a slide using its slide position ISlide slide = presentation.Slides[0]; // Accessing the first and second placeholder in the slide and typecasting it as AutoShape ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame; ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame; // Accessing the first Paragraph IParagraph para1 = tf1.Paragraphs[0]; IParagraph para2 = tf2.Paragraphs[0]; // Justify the paragraph para2.ParagraphFormat.Alignment = TextAlignment.JustifyLow; // Accessing the first portion IPortion port1 = para1.Portions[0]; IPortion port2 = para2.Portions[0]; // Define new fonts FontData fd1 = new FontData("Elephant"); FontData fd2 = new FontData("Castellar"); // Assign new fonts to portion port1.PortionFormat.LatinFont = fd1; port2.PortionFormat.LatinFont = fd2; // Set font to Bold port1.PortionFormat.FontBold = NullableBool.True; port2.PortionFormat.FontBold = NullableBool.True; // Set font to Italic port1.PortionFormat.FontItalic = NullableBool.True; port2.PortionFormat.FontItalic = NullableBool.True; // Set font color port1.PortionFormat.FillFormat.FillType = FillType.Solid; port1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Purple; port2.PortionFormat.FillFormat.FillType = FillType.Solid; port2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Peru; // ExEnd:ManagParagraphFontProperties // Write the PPTX to disk presentation.Save(dataDir + "ManagParagraphFontProperties_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } }
public void IsBold_GetterReturnsFalse_WhenFontOfPlaceholderTextIsNotBold() { // Arrange IAutoShape placeholderAutoShape = (IAutoShape)_fixture.Pre020.Slides[2].Shapes.First(sp => sp.Id == 7); IPortion portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0]; // Act bool isBold = portion.Font.IsBold; // Assert isBold.Should().BeFalse(); }
public static void setdefaultstyle(IAutoShape shape) { ITextFrame tf1 = shape.TextFrame; foreach (var item in tf1.Paragraphs) { IPortion port = item.Portions[0]; port.PortionFormat.LatinFont = new FontData("微软雅黑"); port.PortionFormat.FontBold = NullableBool.NotDefined; port.PortionFormat.FontHeight = 12; } }
public void Text_GetterReturnsParagraphPortionText() { // Arrange IPortion portion = ((ITable)_fixture.Pre009.Slides[2].Shapes.First(sp => sp.Id == 3)).Rows[0].Cells[0].TextBox .Paragraphs[0].Portions[0]; // Act string paragraphPortionText = portion.Text; // Assert paragraphPortionText.Should().BeEquivalentTo("0:0_p1_lvl1"); }
public void Size_GetterReturnsFontSize_OfPlaceholder() { // Arrange IAutoShape autoShapeCase1 = (IAutoShape)_fixture.Pre028.Slides[0].Shapes.First(sp => sp.Id == 4098); IAutoShape autoShapeCase2 = (IAutoShape)_fixture.Pre029.Slides[0].Shapes.First(sp => sp.Id == 3); IPortion portionC1 = autoShapeCase1.TextBox.Paragraphs[0].Portions[0]; IPortion portionC2 = autoShapeCase2.TextBox.Paragraphs[0].Portions[0]; // Act-Assert portionC1.Font.Size.Should().Be(3200); portionC2.Font.Size.Should().Be(2500); }
public void Name_SetterThrowsException_WhenAnUserTryChangeFontNameForPortionOfAPlaceholderShape() { // Arrange IAutoShape autoShape = (IAutoShape)SCPresentation.Open(Resources._001, true).Slides[2].Shapes .First(sp => sp.Id == 4); IPortion paragraphPortion = autoShape.TextBox.Paragraphs[0].Portions[0]; // Act Action action = () => paragraphPortion.Font.Name = "Time New Roman"; // Assert action.Should().Throw <PlaceholderCannotBeChangedException>(); }
public void Text_SetterThrowsElementIsRemovedException_WhenPortionIsRemoved() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._001, true); IAutoShape autoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 5); IPortionCollection portions = autoShape.TextBox.Paragraphs[0].Portions; IPortion portion = portions[0]; portions.Remove(portion); // Act-Assert portion.Invoking(p => p.Text = "new text").Should().Throw <ElementIsRemovedException>(); }
public void Name_SetterChangesFontName() { // Arrange const string newFont = "Time New Roman"; IAutoShape autoShape = SCPresentation.Open(Resources._001, true).Slides[0].Shapes.First(sp => sp.Id == 4) as IAutoShape; IPortion paragraphPortion = autoShape.TextBox.Paragraphs[0].Portions[0]; // Act paragraphPortion.Font.Name = newFont; // Assert paragraphPortion.Font.Name.Should().BeEquivalentTo(newFont); }
public void slide16(ISlide slide) { string str1 = thread4(); IAutoShape itf = (IAutoShape)slide.Shapes[6]; itf.TextFrame.Text = str1; ITextFrame tf = itf.TextFrame; foreach (var item in tf.Paragraphs) { IPortion port = item.Portions[0]; port.PortionFormat.LatinFont = new FontData("微软雅黑"); port.PortionFormat.FontBold = NullableBool.NotDefined; port.PortionFormat.FontHeight = 12; } }
public void IsBold_Setter_AddsBoldForPlaceholderTextFont(SCPresentation presentation, SlideElementQuery portionRequest) { // Arrange MemoryStream mStream = new (); IPortion portion = TestHelper.GetParagraphPortion(presentation, portionRequest); // Act portion.Font.IsBold = true; // Assert portion.Font.IsBold.Should().BeTrue(); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); portion = TestHelper.GetParagraphPortion(presentation, portionRequest); portion.Font.IsBold.Should().BeTrue(); }
public static void Run() { //ExStart:VerticallyAlignText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Tables(); // Create an instance of Presentation class Presentation presentation = new Presentation(); // Get the first slide ISlide slide = presentation.Slides[0]; // Define columns with widths and rows with heights double[] dblCols = { 120, 120, 120, 120 }; double[] dblRows = { 100, 100, 100, 100 }; // Add table shape to slide ITable tbl = slide.Shapes.AddTable(100, 50, dblCols, dblRows); tbl[1, 0].TextFrame.Text = "10"; tbl[2, 0].TextFrame.Text = "20"; tbl[3, 0].TextFrame.Text = "30"; // Accessing the text frame ITextFrame txtFrame = tbl[0, 0].TextFrame; // Create the Paragraph object for text frame IParagraph paragraph = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = paragraph.Portions[0]; portion.Text = "Text here"; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; // Aligning the text vertically ICell cell = tbl[0, 0]; cell.TextAnchorType = TextAnchorType.Center; cell.TextVerticalType = TextVerticalType.Vertical270; // Save Presentation presentation.Save(dataDir + "Vertical_Align_Text_out.pptx", SaveFormat.Pptx); //ExEnd:VerticallyAlignText }
public static void Run() { // ExStart:ApplyOuterShadow // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create an instance of Presentation class Presentation presentation = new Presentation(); // Get reference of a slide ISlide slide = presentation.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 400, 300); ashp.FillFormat.FillType = FillType.NoFill; // Add TextFrame to the Rectangle ashp.AddTextFrame("Aspose TextBox"); IPortion port = ashp.TextFrame.Paragraphs[0].Portions[0]; IPortionFormat pf = port.PortionFormat; pf.FontHeight = 50; // Enable InnerShadowEffect IEffectFormat ef = pf.EffectFormat; ef.EnableInnerShadowEffect(); // Set all necessary parameters ef.InnerShadowEffect.BlurRadius = 8.0; ef.InnerShadowEffect.Direction = 90.0F; ef.InnerShadowEffect.Distance = 6.0; ef.InnerShadowEffect.ShadowColor.B = 189; // Set ColorType as Scheme ef.InnerShadowEffect.ShadowColor.ColorType = ColorType.Scheme; // Set Scheme Color ef.InnerShadowEffect.ShadowColor.SchemeColor = SchemeColor.Accent1; // Save Presentation presentation.Save(dataDir + "WordArt_out.pptx", SaveFormat.Pptx); // ExStart:ApplyOuterShadow }
public static void Run() { // ExStart:ApplyInnerShadow // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate PresentationEx// Instantiate PresentationEx using (Presentation pres = new Presentation()) { // Get the first slide ISlide sld = pres.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; // Set Text portion.Text = "Aspose TextBox"; // ExEnd:ApplyInnerShadow // Save the presentation to disk pres.Save(dataDir + "ApplyInnerShadow_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } }
public void FormatText(Aspose.Slides.Export.ISvgTSpan svgTSpan, IPortion portion, ITextFrame textFrame) { int paragraphIndex = 0; int portionIndex = 0; for (int i = 0; i < textFrame.Paragraphs.Count; i = i + 1) { portionIndex = textFrame.Paragraphs[i].Portions.IndexOf(portion); if (portionIndex > -1) { paragraphIndex = i; break; } } if (m_portionIndex != portionIndex) { m_tspanIndex = 0; m_portionIndex = portionIndex; } svgTSpan.Id = string.Format("paragraph-{0}_portion-{1}_{2}", paragraphIndex, m_portionIndex, m_tspanIndex++); }
public void IsItalic_Setter_SetsItalicFontForForNonPlaceholderText() { // Arrange var mStream = new MemoryStream(); IPresentation presentation = SCPresentation.Open(Resources._020, true); IAutoShape nonPlaceholderAutoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 2); IPortion portion = nonPlaceholderAutoShape.TextBox.Paragraphs[0].Portions[0]; // Act portion.Font.IsItalic = true; // Assert portion.Font.IsItalic.Should().BeTrue(); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); nonPlaceholderAutoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 2); portion = nonPlaceholderAutoShape.TextBox.Paragraphs[0].Portions[0]; portion.Font.IsItalic.Should().BeTrue(); }
public void IsItalic_SetterSetsNonItalicFontForPlaceholderText_WhenFalseValueIsPassed() { // Arrange var mStream = new MemoryStream(); IPresentation presentation = SCPresentation.Open(Resources._020, true); IAutoShape placeholderAutoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 7); IPortion portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0]; // Act portion.Font.IsItalic = false; // Assert portion.Font.IsItalic.Should().BeFalse(); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); placeholderAutoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 7); portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0]; portion.Font.IsItalic.Should().BeFalse(); }
public void Size_SetterChangesFontSizeOfParagraphPortion() { // Arrange int newFontSize = 28; var savedPreStream = new MemoryStream(); SCPresentation presentation = SCPresentation.Open(Resources._001, true); IPortion portion = GetPortion(presentation); int oldFontSize = portion.Font.Size; // Act portion.Font.Size = newFontSize; presentation.SaveAs(savedPreStream); // Assert presentation = SCPresentation.Open(savedPreStream, false); portion = GetPortion(presentation); portion.Font.Size.Should().NotBe(oldFontSize); portion.Font.Size.Should().Be(newFontSize); portion.Font.SizeCanBeChanged().Should().BeTrue(); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Shapes(); Presentation presentation1 = new Presentation(dataDir + "HelloWorld.pptx"); ISlide slide = presentation1.Slides[0]; IAutoShape shp3 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 365, 400, 150); shp3.FillFormat.FillType = FillType.NoFill; shp3.AddTextFrame(" "); ITextFrame txtFrame = shp3.TextFrame; IParagraph para = txtFrame.Paragraphs[0]; IPortion portion = para.Portions[0]; portion.Text = "Watermark Text Watermark Text Watermark Text"; shp3 = slide.Shapes.AddAutoShape(ShapeType.Triangle, 200, 365, 400, 150); slide.Shapes.Reorder(2, shp3); presentation1.Save(dataDir + "Reshape_out.pptx", SaveFormat.Pptx); }
// Generic functions for Slides #region Stage Info private static void StageInfo(ref ISlide sld) { IAutoShape ashp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 20, 300, 200, 300); ashp1.FillFormat.FillType = FillType.NoFill; ashp1.LineFormat.FillFormat.FillType = FillType.NoFill; ITextFrame txtFrame1 = ashp1.TextFrame; txtFrame1.TextFrameFormat.AutofitType = TextAutofitType.Shape; IParagraph para1 = txtFrame1.Paragraphs[0]; para1.Text = "\n Stage 1 = Monitoring \n Stage 2 = ITT Assessment \n Stage 3 = Bid Preparation \n Stage 4 = Bid Submission \n Stage 5 = Mobilisation \n Stage 6 = Post tender review"; para1.ParagraphFormat.Alignment = TextAlignment.Left; // Create Portion object for paragraph IPortion portion1 = para1.Portions[0]; portion1.PortionFormat.FontHeight = 15; portion1.PortionFormat.FontItalic = NullableBool.True; portion1.PortionFormat.FillFormat.FillType = FillType.Solid; portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; }
public void Size_GetterReturnsFontSizeOfTheParagraphPortion() { // Arrange IPortion portionCase1 = ((IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 3)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase2 = ((IAutoShape)_fixture.Pre015.Slides[0].Shapes.First(sp => sp.Id == 5)).TextBox.Paragraphs[0].Portions[2]; IPortion portionCase3 = ((IAutoShape)_fixture.Pre015.Slides[1].Shapes.First(sp => sp.Id == 61)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase4 = ((IAutoShape)_fixture.Pre009.Slides[2].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase5 = ((IAutoShape)_fixture.Pre009.Slides[2].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[1]; IPortion portionCase6 = ((IAutoShape)_fixture.Pre009.Slides[3].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase7 = ((IAutoShape)_fixture.Pre009.Slides[3].Shapes.First(sp => sp.Id == 3)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase8 = ((IAutoShape)_fixture.Pre019.Slides[0].Shapes.First(sp => sp.Id == 4103)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase9 = ((IAutoShape)_fixture.Pre019.Slides[0].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase10 = ((IAutoShape)_fixture.Pre014.Slides[1].Shapes.First(sp => sp.Id == 5)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase11 = ((IAutoShape)_fixture.Pre012.Slides[0].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase12 = ((IAutoShape)_fixture.Pre010.Slides[0].Shapes.First(sp => sp.Id == 2)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase13 = ((IAutoShape)_fixture.Pre014.Slides[3].Shapes.First(sp => sp.Id == 5)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase14 = ((IAutoShape)_fixture.Pre014.Slides[4].Shapes.First(sp => sp.Id == 4)).TextBox.Paragraphs[0].Portions[0]; IPortion portionCase15 = ((IAutoShape)_fixture.Pre014.Slides[5].Shapes.First(sp => sp.Id == 52)).TextBox.Paragraphs[0].Portions[0]; // Act-Assert portionCase1.Font.Size.Should().Be(1800); portionCase2.Font.Size.Should().Be(1800); portionCase3.Font.Size.Should().Be(1867); portionCase4.Font.Size.Should().Be(1800); portionCase5.Font.Size.Should().Be(2000); portionCase6.Font.Size.Should().Be(4400); portionCase7.Font.Size.Should().Be(3200); portionCase8.Font.Size.Should().Be(1800); portionCase9.Font.Size.Should().Be(1200); portionCase10.Font.Size.Should().Be(2177); portionCase11.Font.Size.Should().Be(2000); portionCase12.Font.Size.Should().Be(1539); portionCase13.Font.Size.Should().Be(1200); portionCase14.Font.Size.Should().Be(1200); portionCase15.Font.Size.Should().Be(2700); }
public void slide18(ISlide slide) { Office_ChartStyle style = new Office_ChartStyle(); style.坐标方向 = Base_Config.坐标方向.横向; style.文字位置 = Aspose.Slides.Charts.LegendDataLabelPosition.Center; style.文字旋转方向 = TextVerticalType.Vertical270; style.是否显示文字 = true; Office_Charts.SingleAxexchart(slide, Cache_Result_yb.jsjg_scjgfx, 2, style); IAutoShape itf = (IAutoShape)slide.Shapes[5]; itf.TextFrame.Paragraphs[0].Text = thread5(); itf.TextFrame.Paragraphs[1].Text = thread6(); ITextFrame tf = itf.TextFrame; foreach (var item in tf.Paragraphs) { IPortion port = item.Portions[0]; port.PortionFormat.LatinFont = new FontData("微软雅黑"); port.PortionFormat.FontBold = NullableBool.NotDefined; port.PortionFormat.FontHeight = 12; } }
static void Main(string[] args) { MainAsync(args).Wait(); string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName.ToString(); // Directory Path string JsonData = File.ReadAllText(Path.GetFullPath(path) + "\\Json\\project.json"); //for temporary usage ..for production mainasync method will be used for fetching data ProjectModel pmodel = new ProjectModel(); pmodel = JsonConvert.DeserializeObject <ProjectModel>(JsonData); //Instantiate Prsentation class that represents the PPTX Presentation pres = new Presentation(); //Get the first slide string currentDir = Path.GetFullPath(path) + "\\pptFolder\\"; ISlide sld = pres.Slides[0]; sld.Name = "Existing Tender"; //formatting Text PortionFormat portionFormat = new PortionFormat(); portionFormat.FontHeight = 10; ProjectSummary.Logo(); #region Border IAutoShape borderLines = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 3, 3, 715, 535); borderLines.FillFormat.FillType = FillType.NoFill; borderLines.FillFormat.SolidFillColor.Color = Color.Black; #endregion #region Background //Add some text IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 350, 20); //ashp.FillFormat.FillType = FillType.NoFill; //ashp.LineFormat.FillFormat.FillType = FillType.NoFill; // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); ashp.FillFormat.SolidFillColor.Color = Color.DarkCyan; // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; // Set Text portion.Text = "Background"; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.White; portion.PortionFormat.FontBold = NullableBool.True; #region Table 1 double[] dblCols1 = { 60, 100, 190 }; double[] dblRows1 = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; ITable tb1 = sld.Shapes.AddTable(10, 40, dblCols1, dblRows1); for (int i = 0; i < tb1.Rows.Count; i++) { for (int j = 0; j < tb1.Rows[i].Count; j++) { //adding border to each cell of the table tb1[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderTop.Width = 1; tb1[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderBottom.Width = 1; tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderLeft.Width = 1; tb1[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderRight.Width = 1; //cell with white background tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first column if (j == 0) { tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } //for 7th to last custom row if (i >= 7) { tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.White; tb1[j, i].BorderLeft.Width = 1; tb1[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.White; tb1[j, i].BorderBottom.Width = 1; tb1[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.White; tb1[j, i].BorderRight.Width = 1; tb1[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.White; tb1[j, i].BorderTop.Width = 1; if (i == 7) { tb1[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderTop.Width = 1; } if (j == 2) { tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderLeft.Width = 1; } if (j == 2) { tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderLeft.Width = 1; } tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.White; } } } tb1.SetTextFormat(portionFormat); Bitmap image = new Bitmap(currentDir + "imagelogo.jpg"); // Create an IPPImage object using the bitmap object IPPImage imgx1 = pres.Images.AddImage(image); // Add image to column 2 table cell tb1[2, 0].FillFormat.FillType = FillType.Picture; tb1[2, 0].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; tb1[2, 0].FillFormat.PictureFillFormat.Picture.Image = imgx1; tb1.MergeCells(tb1[2, 0], tb1[2, 1], false); tb1.MergeCells(tb1[2, 0], tb1[2, 2], false); tb1.MergeCells(tb1[2, 0], tb1[2, 3], false); tb1.MergeCells(tb1[2, 0], tb1[2, 4], false); tb1.MergeCells(tb1[2, 0], tb1[2, 5], false); tb1.MergeCells(tb1[2, 0], tb1[2, 6], false); tb1.MergeCells(tb1[2, 0], tb1[2, 7], false); tb1.MergeCells(tb1[2, 0], tb1[2, 8], false); tb1.MergeCells(tb1[2, 0], tb1[2, 9], false); #endregion //column Names: tb1[0, 0].TextFrame.Text = "ProjectName"; tb1[0, 1].TextFrame.Text = "Country"; tb1[0, 2].TextFrame.Text = "Region"; tb1[0, 3].TextFrame.Text = "Mode"; tb1[0, 4].TextFrame.Text = "Project Type"; tb1[0, 5].TextFrame.Text = "Project Id"; tb1[0, 6].TextFrame.Text = "Updated Date"; //inserting values from project tb1[1, 0].TextFrame.Text = pmodel.ProjectName; tb1[1, 1].TextFrame.Text = pmodel.Country; tb1[1, 2].TextFrame.Text = pmodel.Region; tb1[1, 3].TextFrame.Text = Enum.GetName(typeof(EnumValue.Mode), pmodel.Mode); tb1[1, 4].TextFrame.Text = Enum.GetName(typeof(EnumValue.TenderStatus), pmodel.DealStatus); tb1[1, 5].TextFrame.Text = pmodel.ProjectId; tb1[1, 6].TextFrame.Text = "7/09/2017"; #region Table 2 double[] coltbl2 = { 350 }; double[] rowtbl2 = { 20, 50, 20, 50 }; ITable tb2 = sld.Shapes.AddTable(10, 230, coltbl2, rowtbl2); for (int i = 0; i < tb2.Rows.Count; i++) { for (int j = 0; j < tb2.Rows[i].Count; j++) { //border for each cell tb2[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderTop.Width = 1; tb2[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderBottom.Width = 1; tb2[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderLeft.Width = 1; tb2[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderRight.Width = 1; tb2[j, i].FillFormat.FillType = FillType.Solid; if (i % 2 == 0) { tb2[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } else { tb2[j, i].FillFormat.SolidFillColor.Color = Color.White; } } } //Text Entry tb2[0, 0].TextFrame.Text = "Description"; tb2[0, 1].TextFrame.Text = pmodel.Description; tb2[0, 2].TextFrame.Text = "Strategic Rationale"; tb2[0, 3].TextFrame.Text = pmodel.StrategicRationale; tb2.SetTextFormat(portionFormat); #endregion #region Table 3 // Table 3a double[] coltbl3a = { 40, 40, 40, 40 }; double[] rowtbl3a = { 10, 10, 10, 10, 10 }; ITable tb3a = sld.Shapes.AddTable(10, 400, coltbl3a, rowtbl3a); portionFormat.FontHeight = 10; tb3a.SetTextFormat(portionFormat); for (int i = 0; i < tb3a.Rows.Count; i++) { for (int j = 0; j < tb3a.Rows[i].Count; j++) { tb3a[j, i].FillFormat.FillType = FillType.Solid; if (i == 0 && j == 0) { tb3a[j, i].FillFormat.FillType = FillType.NoFill; } else { if ((i == 0 && j > 0) || (j == 0 && i > 0)) { tb3a[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } else { tb3a[j, i].FillFormat.SolidFillColor.Color = Color.White; } //border for each cell tb3a[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb3a[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb3a[j, i].BorderTop.Width = 1; tb3a[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb3a[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb3a[j, i].BorderBottom.Width = 1; tb3a[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb3a[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb3a[j, i].BorderLeft.Width = 1; tb3a[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb3a[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb3a[j, i].BorderRight.Width = 1; } } } //column names: tb3a[1, 0].TextFrame.Text = "2017"; tb3a[2, 0].TextFrame.Text = "2018"; tb3a[3, 0].TextFrame.Text = "2019"; tb3a[0, 1].TextFrame.Text = "Revenue"; tb3a[0, 2].TextFrame.Text = "EBIT"; tb3a[0, 3].TextFrame.Text = "Capex"; tb3a[0, 4].TextFrame.Text = "MTP"; tb3a[1, 1].TextFrame.Text = pmodel.RevenueX.ToString(); tb3a[2, 1].TextFrame.Text = pmodel.RevenueX1.ToString(); tb3a[3, 1].TextFrame.Text = pmodel.RevenueX2.ToString(); tb3a[1, 2].TextFrame.Text = pmodel.EbitX.ToString(); tb3a[2, 2].TextFrame.Text = pmodel.EbitX1.ToString(); tb3a[3, 2].TextFrame.Text = pmodel.EbitX2.ToString(); tb3a[1, 3].TextFrame.Text = pmodel.CAPEXXMEuro.ToString(); tb3a[2, 3].TextFrame.Text = pmodel.CAPEX1MEuro.ToString(); tb3a[3, 3].TextFrame.Text = pmodel.CAPEX2MEuro.ToString(); // Table 3b double[] coltbl3b = { 100, 50 }; double[] rowtbl3b = { 10, 10, 10 }; ITable tb3b = sld.Shapes.AddTable(200, 400, coltbl3b, rowtbl3b); portionFormat.FontHeight = 10; tb3b.SetTextFormat(portionFormat); for (int i = 0; i < tb3b.Rows.Count; i++) { for (int j = 0; j < tb3b.Rows[i].Count; j++) { tb3b[j, i].FillFormat.FillType = FillType.Solid; if (j == 0) { tb3b[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } else { tb3b[j, i].FillFormat.SolidFillColor.Color = Color.White; } //border for each cell tb3b[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb3b[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb3b[j, i].BorderTop.Width = 1; tb3b[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb3b[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb3b[j, i].BorderBottom.Width = 1; tb3b[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb3b[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb3b[j, i].BorderLeft.Width = 1; tb3b[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb3b[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb3b[j, i].BorderRight.Width = 1; } } //columns name tb3b[0, 0].TextFrame.Text = "EBIT"; tb3b[0, 1].TextFrame.Text = "Number of vehicles"; tb3b[0, 2].TextFrame.Text = "Contract Length"; tb3b[0, 0].TextFrame.Text = pmodel.New_or_existingwork.ToString(); tb3b[0, 1].TextFrame.Text = pmodel.NumberOfVehicles.ToString(); tb3b[0, 2].TextFrame.Text = pmodel.CoreContractLength.ToString(); #endregion #endregion #region Status //Add some text IAutoShape ashp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 400, 10, 300, 20); // Add TextFrame to the Rectangle ashp1.AddTextFrame(""); ashp1.FillFormat.SolidFillColor.Color = Color.DarkCyan; // Accessing the text frame ITextFrame txtFrame1 = ashp1.TextFrame; // Create the Paragraph object for text frame IParagraph para1 = txtFrame1.Paragraphs[0]; // Create Portion object for paragraph IPortion portion1 = para1.Portions[0]; // Set Text portion1.Text = "Status"; portion1.PortionFormat.FillFormat.FillType = FillType.Solid; portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.White; portion1.PortionFormat.FontBold = NullableBool.True; #region Table 4 //Define columns with widths and rows with heights //double[] dblCols = { 50, 50, 50 }; double[] dblCols = { 80, 100, 60, 60 }; double[] dblRows = { 20, 20, 20, 20, 40, 30 }; //Add table shape to slide ITable tb4 = sld.Shapes.AddTable(400, 40, dblCols, dblRows); tb4.SetTextFormat(portionFormat); for (int i = 0; i < tb4.Rows.Count; i++) { for (int j = 0; j < tb4.Rows[i].Count; j++) { //adding border to each cell of the table tb4[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb4[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb4[j, i].BorderTop.Width = 1; tb4[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb4[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb4[j, i].BorderBottom.Width = 1; tb4[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb4[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb4[j, i].BorderLeft.Width = 1; tb4[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb4[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb4[j, i].BorderRight.Width = 1; //cell with white background tb4[j, i].FillFormat.FillType = FillType.Solid; tb4[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first column if (j == 0) { tb4[j, i].FillFormat.FillType = FillType.Solid; tb4[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } //color for cell //caution: color it before split otherwise left portion of split cell will be coloured tb4[3, 5].FillFormat.FillType = FillType.Solid; tb4[3, 5].FillFormat.SolidFillColor.Color = Color.ForestGreen; tb4.SetTextFormat(portionFormat); //Set border format for each cell //Merge cells 1 & 2 of row 1 tb4.MergeCells(tb4[1, 4], tb4[2, 4], false); tb4.MergeCells(tb4[2, 4], tb4[3, 4], false); tb4.MergeCells(tb4[1, 5], tb4[2, 5], false); tb4[3, 5].SplitByWidth(tb4[3, 5].Width / 2); tb4.MergeCells(tb4[2, 5], tb4[3, 5], false); // tb4[1, 4].TextFrame.Text = ""; //column names: tb4[0, 0].TextFrame.Text = "Division Responsible"; tb4[0, 1].TextFrame.Text = "Executive Board Member"; tb4[0, 2].TextFrame.Text = "Country Manager"; tb4[0, 3].TextFrame.Text = "Project Manager"; tb4[0, 4].TextFrame.Text = "Team Members(and role) OR requirements"; tb4[0, 5].TextFrame.Text = "Uncovered Team Resources"; tb4[2, 0].TextFrame.Text = "Contract Type"; tb4[2, 1].TextFrame.Text = "Project Stage"; tb4[2, 2].TextFrame.Text = "Type"; tb4[2, 3].TextFrame.Text = "Probability"; //project values: tb4[1, 0].TextFrame.Text = pmodel.AdditionalTeamMembers; tb4[1, 1].TextFrame.Text = pmodel.ExecutiveBoardMember; tb4[1, 2].TextFrame.Text = pmodel.CountryManager; tb4[1, 3].TextFrame.Text = pmodel.ProjectManager; tb4[1, 4].TextFrame.Text = pmodel.UncoveredTeamResources; tb4[2, 0].TextFrame.Text = Enum.GetName(typeof(EnumValue.ContractType), pmodel.ContractType); tb4[2, 1].TextFrame.Text = Enum.GetName(typeof(EnumValue.ContractType), pmodel.ProjectStageTender); tb4[2, 2].TextFrame.Text = "A(>500)"; tb4[2, 3].TextFrame.Text = "60%"; #endregion #region Table 5 double[] dblCols5 = { 80, 160, 30, 30 }; double[] dblRows5 = { 10, 10, 10, 10, 10, 10, 10, 10, 10 }; ITable tb5 = sld.Shapes.AddTable(400, 200, dblCols5, dblRows5); for (int i = 0; i < tb5.Rows.Count; i++) { for (int j = 0; j < tb5.Rows[i].Count; j++) { //adding border to each cell of the table tb5[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb5[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb5[j, i].BorderTop.Width = 1; tb5[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb5[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb5[j, i].BorderBottom.Width = 1; tb5[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb5[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb5[j, i].BorderLeft.Width = 1; tb5[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb5[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb5[j, i].BorderRight.Width = 1; //cell with white background tb5[j, i].FillFormat.FillType = FillType.Solid; tb5[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first column if (i < 2 || j == 3) { tb5[j, i].FillFormat.FillType = FillType.Solid; tb5[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } tb5.SetTextFormat(portionFormat); //column names: tb5[0, 0].TextFrame.Text = "KeyMilestone & Action"; tb5[0, 1].TextFrame.Text = "Date"; tb5[1, 1].TextFrame.Text = "Task/Event"; tb5[2, 1].TextFrame.Text = "Resp"; tb5[3, 1].TextFrame.Text = "Status"; for (int i = 2; i <= pmodel.KeyMileStoneAndAction.Count + 1; i++) { tb5[0, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Date; tb5[1, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].TaskEvent; tb5[2, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Resp; tb5[3, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Status; } #endregion #region Table 6 double[] dblCols6 = { 300 }; double[] dblRows6 = { 20, 40 }; ITable tb6 = sld.Shapes.AddTable(400, 380, dblCols6, dblRows6); tb6.SetTextFormat(portionFormat); for (int i = 0; i < tb6.Rows.Count; i++) { for (int j = 0; j < tb6.Rows[i].Count; j++) { //adding border to each cell of the table tb6[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb6[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb6[j, i].BorderTop.Width = 1; tb6[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb6[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb6[j, i].BorderBottom.Width = 1; tb6[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb6[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb6[j, i].BorderLeft.Width = 1; tb6[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb6[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb6[j, i].BorderRight.Width = 1; //cell with white background tb6[j, i].FillFormat.FillType = FillType.Solid; tb6[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first column if (i == 0 && j == 0) { tb6[j, i].FillFormat.FillType = FillType.Solid; tb6[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } #endregion tb6[0, 0].TextFrame.Text = "Status Description"; tb6[0, 1].TextFrame.Text = pmodel.StatusDescription; #region Table 7 double[] dblCols7 = { 240, 30, 30 }; double[] dblRows7 = { 20, 20, 20, 20 }; ITable tb7 = sld.Shapes.AddTable(400, 445, dblCols7, dblRows7); tb7.SetTextFormat(portionFormat); for (int i = 0; i < tb7.Rows.Count; i++) { for (int j = 0; j < tb7.Rows[i].Count; j++) { //adding border to each cell of the table tb7[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb7[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb7[j, i].BorderTop.Width = 1; tb7[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb7[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb7[j, i].BorderBottom.Width = 1; tb7[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb7[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb7[j, i].BorderLeft.Width = 1; tb7[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb7[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb7[j, i].BorderRight.Width = 1; //cell with white background tb7[j, i].FillFormat.FillType = FillType.Solid; tb7[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first column if (i == 0) { tb7[j, i].FillFormat.FillType = FillType.Solid; tb7[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } #endregion tb7[0, 0].TextFrame.Text = "Issue For Discussion"; for (int i = 1; i <= pmodel.Issues.Count; i++) { tb7[0, i].TextFrame.Text = pmodel.Issues[i - 1].Issues; tb7[1, i].TextFrame.Text = pmodel.Issues[i - 1].Owner; tb7[2, i].TextFrame.Text = pmodel.Issues[i - 1].Date; } #endregion #region projectsummary ProjectSummary.ProjSummary1(ref pres); #endregion #region Opportunities Schedule ProjectSummary.OpportunitiesSchedule(ref pres); #endregion Console.Write("ppt in progress"); pres.Save(currentDir + "Table.pptx", Export.SaveFormat.Pptx); }
public static void ProjSummary1(ref Presentation p) { //formatting font text for table TextFrame PortionFormat portionFormat = new PortionFormat(); portionFormat.FontHeight = 10; IMasterLayoutSlideCollection layoutSlides = p.Masters[0].LayoutSlides; ILayoutSlide layoutSlide = layoutSlides.GetByType(SlideLayoutType.TitleAndObject) ?? layoutSlides.GetByType(SlideLayoutType.Title); p.Slides.AddEmptySlide(layoutSlide); #region Table Rows/Column double[] dblCols = { 20, 150, 50, 50, 150, 150, 50, 50 }; double[] dblRows = { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }; #endregion #region project summary (1/3) ISlide sld = p.Slides[1]; sld.Name = "Project Summary sheet 1"; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 35, 350, 50); ashp.FillFormat.FillType = FillType.NoFill; ashp.LineFormat.FillFormat.FillType = FillType.NoFill; // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; portion.PortionFormat.FontHeight = 25; IPortionFormat pf = portion.PortionFormat; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.DarkCyan; portion.PortionFormat.FontBold = NullableBool.True; // Set Text portion.Text = "Projects Summary (1/3) – existing tenders (Priority 1)"; //existing tenders //Add table shape to slide ITable tb1 = sld.Shapes.AddTable(30, 100, dblCols, dblRows); for (int i = 0; i < tb1.Rows.Count; i++) { for (int j = 0; j < tb1.Rows[i].Count; j++) { //adding border to each cell of the table tb1[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderTop.Width = 1; tb1[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderBottom.Width = 1; tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderLeft.Width = 1; tb1[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderRight.Width = 1; //cell with white background tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first row if (i == 0) { tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } tb1[0, 0].TextFrame.Text = "Nr"; tb1[1, 0].TextFrame.Text = "Existing Tenders"; tb1[2, 0].TextFrame.Text = "RAG current month"; tb1[3, 0].TextFrame.Text = "RAG previous month"; tb1[4, 0].TextFrame.Text = "Issue/Key Milestone"; tb1[5, 0].TextFrame.Text = "Action agreed"; tb1[6, 0].TextFrame.Text = "Project Manger"; tb1[7, 0].TextFrame.Text = "Accountable"; tb1.SetTextFormat(portionFormat); #endregion #region project summary(2/3) p.Slides.AddEmptySlide(layoutSlide); ISlide sld1 = p.Slides[2]; sld1.Name = "Project Summary sheet 2"; // Add an AutoShape of Rectangle type ashp = sld1.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 35, 400, 50); ashp.FillFormat.FillType = FillType.NoFill; ashp.LineFormat.FillFormat.FillType = FillType.NoFill; //// Add TextFrame to the Rectangle ashp.AddTextFrame(" "); // Accessing the text frame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph portion = para.Portions[0]; portion.PortionFormat.FontHeight = 25; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.DarkCyan; portion.PortionFormat.FontBold = NullableBool.True; // Set Text portion.Text = "Projects Summary (2/3) – new tenders"; //Add table shape to slide ITable tb2 = sld1.Shapes.AddTable(30, 100, dblCols, dblRows); for (int i = 0; i < tb2.Rows.Count; i++) { for (int j = 0; j < tb2.Rows[i].Count; j++) { //adding border to each cell of the table tb2[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderTop.Width = 1; tb2[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderBottom.Width = 1; tb2[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderLeft.Width = 1; tb2[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderRight.Width = 1; //cell with white background tb2[j, i].FillFormat.FillType = FillType.Solid; tb2[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first row if (i == 0) { tb2[j, i].FillFormat.FillType = FillType.Solid; tb2[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } tb2[0, 0].TextFrame.Text = "Nr"; tb2[1, 0].TextFrame.Text = "Existing Tenders"; tb2[2, 0].TextFrame.Text = "RAG current month"; tb2[3, 0].TextFrame.Text = "RAG previous month"; tb2[4, 0].TextFrame.Text = "Issue/Key Milestone"; tb2[5, 0].TextFrame.Text = "Action agreed"; tb2[6, 0].TextFrame.Text = "Project Manger"; tb2[7, 0].TextFrame.Text = "Accountable"; tb2.SetTextFormat(portionFormat); #endregion #region project summary(3/3) p.Slides.AddEmptySlide(layoutSlide); ISlide sld2 = p.Slides[3]; sld2.Name = "Project Summary sheet 3"; // Add an AutoShape of Rectangle type ashp = sld2.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 35, 400, 50); ashp.FillFormat.FillType = FillType.NoFill; ashp.LineFormat.FillFormat.FillType = FillType.NoFill; //// Add TextFrame to the Rectangle ashp.AddTextFrame(" "); // Accessing the text frame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph portion = para.Portions[0]; portion.PortionFormat.FontHeight = 25; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.DarkCyan; portion.PortionFormat.FontBold = NullableBool.True; // Set Text portion.Text = "Projects Summary (3/3) – M&A existing and new countries"; //Add table shape to slide ITable tb3 = sld2.Shapes.AddTable(30, 100, dblCols, dblRows); for (int i = 0; i < tb3.Rows.Count; i++) { for (int j = 0; j < tb3.Rows[i].Count; j++) { //adding border to each cell of the table tb3[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb3[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb3[j, i].BorderTop.Width = 1; tb3[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb3[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb3[j, i].BorderBottom.Width = 1; tb3[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb3[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb3[j, i].BorderLeft.Width = 1; tb3[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb3[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb3[j, i].BorderRight.Width = 1; //cell with white background tb3[j, i].FillFormat.FillType = FillType.Solid; tb3[j, i].FillFormat.SolidFillColor.Color = Color.White; //Grey color for first row if (i == 0) { tb3[j, i].FillFormat.FillType = FillType.Solid; tb3[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } tb3[0, 0].TextFrame.Text = "Nr"; tb3[1, 0].TextFrame.Text = "Growth Opportunities (Tenders): Priority 1"; tb3[2, 0].TextFrame.Text = "RAG current month"; tb3[3, 0].TextFrame.Text = "RAG previous month"; tb3[4, 0].TextFrame.Text = "Issue/Key Milestone"; tb3[5, 0].TextFrame.Text = "Action agreed"; tb3[6, 0].TextFrame.Text = "Project Manger"; tb3[7, 0].TextFrame.Text = "Accountable"; tb3.SetTextFormat(portionFormat); #endregion }
public static void OpportunitiesSchedule(ref Presentation p) { PortionFormat portionFormat = new PortionFormat(); portionFormat.FontHeight = 10; IMasterLayoutSlideCollection layoutSlides = p.Masters[0].LayoutSlides; ILayoutSlide layoutSlide = layoutSlides.GetByType(SlideLayoutType.TitleAndObject) ?? layoutSlides.GetByType(SlideLayoutType.Title); //add new slide in presentation p.Slides.AddEmptySlide(layoutSlide); #region Table Rows/Column double[] dblCols = { 10, 20, 30, 100, 20, 40, 40, 40, 50, 30, 30, 30, 30, 30, 30, 30, 30, 40, 70 }; double[] dblRows = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; #endregion #region Opportunities Schedule – Existing Tenders by Priority ISlide sld = p.Slides[4]; sld.Name = "Opportunities Schedule sheet 1"; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 35, 350, 50); ashp.FillFormat.FillType = FillType.NoFill; ashp.LineFormat.FillFormat.FillType = FillType.NoFill; // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; portion.PortionFormat.FontHeight = 25; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.DarkCyan; portion.PortionFormat.FontBold = NullableBool.True; // Set Text portion.Text = "Opportunities Schedule – Existing Tenders by Priority"; //Add table shape to slide ITable tb1 = sld.Shapes.AddTable(5, 100, dblCols, dblRows); for (int i = 0; i < tb1.Rows.Count; i++) { for (int j = 0; j < tb1.Rows[i].Count; j++) { if (i == 9 && (j < 8 || j > 17)) { tb1[j, i].FillFormat.FillType = FillType.NoFill; } else { //adding border to each cell of the table tb1[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderTop.Width = 1; tb1[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderBottom.Width = 1; tb1[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderLeft.Width = 1; tb1[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb1[j, i].BorderRight.Width = 1; //cell with white background tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.White; } //Grey color for first row if (i == 0) { tb1[j, i].FillFormat.FillType = FillType.Solid; tb1[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } for (int j = 0; j < tb1.Rows[0].Count; j++) { //Merge first and second row in header for specific column if (j < 8 || j > 17) { tb1.MergeCells(tb1[j, 0], tb1[j, 1], false); } // merge three columns in first row if (j == 9 || j == 12 || j == 15) { tb1.MergeCells(tb1[j, 0], tb1[j + 1, 0], false); tb1.MergeCells(tb1[j, 0], tb1[j + 2, 0], false); } } tb1[0, 0].TextFrame.Text = "#"; tb1[1, 0].TextFrame.Text = "BU"; tb1[2, 0].TextFrame.Text = "Priority"; tb1[3, 0].TextFrame.Text = "Existing Tenders"; tb1[4, 0].TextFrame.Text = "Stage"; tb1[5, 0].TextFrame.Text = "Contract Date"; tb1[6, 0].TextFrame.Text = "Directors Approval"; tb1[7, 0].TextFrame.Text = "Team Yrs."; tb1[8, 0].TextFrame.Text = "Category"; tb1[9, 0].TextFrame.Text = " "; tb1[10, 0].TextFrame.Text = ""; tb1[11, 0].TextFrame.Text = "Revenue (€m)"; tb1[12, 0].TextFrame.Text = ""; tb1[13, 0].TextFrame.Text = ""; tb1[14, 0].TextFrame.Text = "EBIT (€m)"; tb1[15, 0].TextFrame.Text = ""; tb1[16, 0].TextFrame.Text = ""; tb1[17, 0].TextFrame.Text = "CAPEX (€m)"; tb1[18, 0].TextFrame.Text = "EBIT/CAPEX"; tb1[8, 9].TextFrame.Text = "Total MTP"; //txtFrame = tb1[8, 9].TextFrame; tb1.SetTextFormat(portionFormat); StageInfo(ref sld); #endregion #region "Opportunities Schedule – New Tenders by priority" p.Slides.AddEmptySlide(layoutSlide); ISlide sld1 = p.Slides[5]; #region Table Rows/Column double[] dblCols1 = { 10, 20, 30, 100, 20, 40, 40, 40, 50, 30, 30, 30, 30, 30, 30, 30, 30, 40, 70 }; double[] dblRows1 = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; #endregion IAutoShape ashp1 = sld1.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 35, 350, 50); ashp1.FillFormat.FillType = FillType.NoFill; ashp1.LineFormat.FillFormat.FillType = FillType.NoFill; ashp1.AddTextFrame(" "); // Accessing the text frame ITextFrame txtFrame1 = ashp1.TextFrame; // Create the Paragraph object for text frame IParagraph para1 = txtFrame1.Paragraphs[0]; // Create Portion object for paragraph IPortion portion1 = para1.Portions[0]; portion1.PortionFormat.FontHeight = 25; portion1.PortionFormat.FillFormat.FillType = FillType.Solid; portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.DarkCyan; portion1.PortionFormat.FontBold = NullableBool.True; // Set Text portion1.Text = "Opportunities Schedule – New Tenders by Priority"; //Add table shape to slide ITable tb2 = sld1.Shapes.AddTable(5, 100, dblCols, dblRows); for (int i = 0; i < tb2.Rows.Count; i++) { for (int j = 0; j < tb2.Rows[i].Count; j++) { if ((i == 9 || i == 4) && (j < 8 || j > 17)) { tb2[j, i].FillFormat.FillType = FillType.NoFill; } //else if (i == 4 && (j < 8 || j > 17)) //{ // tb2[j, i].FillFormat.FillType = FillType.NoFill; //} else { //adding border to each cell of the table tb2[j, i].BorderTop.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderTop.Width = 1; tb2[j, i].BorderBottom.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderBottom.Width = 1; tb2[j, i].BorderLeft.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderLeft.Width = 1; tb2[j, i].BorderRight.FillFormat.FillType = FillType.Solid; tb2[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black; tb2[j, i].BorderRight.Width = 1; //cell with white background tb2[j, i].FillFormat.FillType = FillType.Solid; tb2[j, i].FillFormat.SolidFillColor.Color = Color.White; } //Grey color for first row if (i == 0) { tb2[j, i].FillFormat.FillType = FillType.Solid; tb2[j, i].FillFormat.SolidFillColor.Color = Color.Gray; } } } for (int j = 0; j < tb2.Rows[0].Count; j++) { //Merge first and second row in header for specific column if (j < 8 || j > 17) { tb2.MergeCells(tb2[j, 0], tb2[j, 1], false); } // merge three columns in first row if (j == 9 || j == 12 || j == 15) { tb2.MergeCells(tb2[j, 0], tb2[j + 1, 0], false); tb2.MergeCells(tb2[j, 0], tb2[j + 2, 0], false); } } tb2[8, 4].TextFrame.Text = "TOTAL MTP"; tb2[0, 0].TextFrame.Text = "#"; tb2[1, 0].TextFrame.Text = "BU"; tb2[2, 0].TextFrame.Text = "Priority"; tb2[3, 0].TextFrame.Text = "New Tenders"; tb2[4, 0].TextFrame.Text = "Stage"; tb2[5, 0].TextFrame.Text = "Contract Date"; tb2[6, 0].TextFrame.Text = "Directors Approval"; tb2[7, 0].TextFrame.Text = "Team Yrs."; tb2[8, 0].TextFrame.Text = "Category"; tb2[9, 0].TextFrame.Text = " "; tb2[10, 0].TextFrame.Text = ""; tb2[11, 0].TextFrame.Text = "Revenue (€m)"; tb2[12, 0].TextFrame.Text = ""; tb2[13, 0].TextFrame.Text = ""; tb2[14, 0].TextFrame.Text = "EBIT (€m)"; tb2[15, 0].TextFrame.Text = ""; tb2[16, 0].TextFrame.Text = ""; tb2[17, 0].TextFrame.Text = "CAPEX (€m)"; tb2[18, 0].TextFrame.Text = "EBIT/CAPEX"; tb2[8, 9].TextFrame.Text = "Total MTP"; //txtFrame = tb2[8, 9].TextFrame; tb2.SetTextFormat(portionFormat); StageInfo(ref sld1); #endregion }