Add SmartArt to Slide in C#

PowerPoint SmartArt is a special type of graphic object that gives you the ability to construct fancy graphical lists and diagrams in your slide quickly and easily. With just one click, you’re able to create a flow chart, an organization chart or a timeline in slide. This article gives you an example of how to add an organization chart to slide using Spire.Presentation with C#.

//create an instance of Presentation
Presentation ppt = new Presentation();

//set slide size
ppt.SlideSize.Type = SlideSizeType.Screen16x9;

//append an organization chart and specify position and size
ISmartArt smartArt = ppt.Slides[0].Shapes.AppendSmartArt(50, 50, 450, 250, SmartArtLayoutType.OrganizationChart);

//set the style and color of smartart
smartArt.Style = SmartArtStyleType.IntenceEffect;
smartArt.ColorStyle = SmartArtColorType.ColorfulAccentColors3to4;

//remove default notes (represent shape in smartart)
foreach (ISmartArtNode node in smartArt.Nodes)

//add nested shapes to smartart
ISmartArtNode node1 = smartArt.Nodes.AddNode();
ISmartArtNode node1_1 = node1.ChildNodes.AddNode();
ISmartArtNode node1_1_1 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_2 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_3 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_4 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_5 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_6 = node1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_1_1 = node1_1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_1_2 = node1_1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_1_3 = node1_1_1.ChildNodes.AddNode();
ISmartArtNode node1_1_3_1 = node1_1_3.ChildNodes.AddNode();
ISmartArtNode node1_1_3_2 = node1_1_3.ChildNodes.AddNode();
ISmartArtNode node1_1_6_1 = node1_1_6.ChildNodes.AddNode();
ISmartArtNode node1_1_6_2 = node1_1_6.ChildNodes.AddNode();
ISmartArtNode node1_1_6_3 = node1_1_6.ChildNodes.AddNode();

//add text to each shape
node1.TextFrame.Text = "Board of Directors";
node1_1.TextFrame.Text = "General Manager";
node1_1_1.TextFrame.Text = "Supply Department";
node1_1_2.TextFrame.Text = "Sales Department";
node1_1_3.TextFrame.Text = "Productive Department";
node1_1_4.TextFrame.Text = "Finance Department";
node1_1_5.TextFrame.Text = "HR Department";
node1_1_6.TextFrame.Text = "Quality Center";
node1_1_1_1.TextFrame.Text = "Purchase Department";
node1_1_1_2.TextFrame.Text = "Warehouse Manager";
node1_1_1_3.TextFrame.Text = "Logistics Department";
node1_1_3_1.TextFrame.Text = "Production Department";
node1_1_3_2.TextFrame.Text = "Maintenance Department";
node1_1_6_1.TextFrame.Text = "Production Quality Management";
node1_1_6_2.TextFrame.Text = "Production Safety Management";
node1_1_6_3.TextFrame.Text = "Environmental Management";

//save to file
ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s