Knowledgebase (2345)
Children categories
As is shown in the following presentation slide, shapes automatically stack in separate layers as you add them. To change the order of overlapping shapes, we can move the layers forward and backward. But how can we achieve this task programmatically using C# or VB.NET? This article is aimed to present you a solution on how to reorder overlapping shapes using Spire.Presentation.

In the early edition, Spire.Presentation is already capable of adding different kinds of shapes to the slides, setting color and fill style of the shape. In the Version2.0.18, we add reordering overlapping shapes as a new feature to satisfy our customer’s demands. Now, let’s see how to make it happen with sample code snippet.
Step 1: Create a new instance of Spire.Presentation class and load the test file.
Spire.Presentation.Presentation presentation = new Presentation();
presentation.LoadFromFile("..\\..\\test.pptx");
Step 2: Get the first shape from the slide.
IShape shape = presentation.Slides[0].Shapes[0];
Step 3: Change the shape's Zorder by setting its position index.
presentation.Slides[0].Shapes.ZOrder(1, shape);
Step 4: Save to a PPTX file and launch the file.
string output = "output.pptx"; presentation.SaveToFile(output,FileFormat.Pptx2010); System.Diagnostics.Process.Start(output);
Output:

Full code:
using Spire.Presentation;
namespace ReorderOverlappingShape
{
class Program
{
static void Main(string[] args)
{
//Create an instance of Spire.Presentation
Spire.Presentation.Presentation presentation = new Presentation();
//Load a pptx file
presentation.LoadFromFile("..\\..\\test.pptx");
//Get the first shape of the first slide
IShape shape = presentation.Slides[0].Shapes[0];
//Change the shape's zorder
presentation.Slides[0].Shapes.ZOrder(1, shape);
//Save to a pptx2010 file.
string output = "output.pptx";
presentation.SaveToFile(output, FileFormat.Pptx2010);
//Launch the output file
System.Diagnostics.Process.Start(output);
}
}
}
Imports Spire.Presentation
Namespace ReorderOverlappingShape
Class Program
Private Shared Sub Main(args As String())
'Create an instance of Spire.Presentation
Dim presentation As Spire.Presentation.Presentation = New Presentation()
'Load a pptx file
presentation.LoadFromFile("..\..\test.pptx")
'Get the first shape of the first slide
Dim shape As IShape = presentation.Slides(0).Shapes(0)
'Change the shape's zorder
presentation.Slides(0).Shapes.ZOrder(1, shape)
'Save to a pptx2010 file.
Dim output As String = "output.pptx"
presentation.SaveToFile(output, FileFormat.Pptx2010)
'Launch the output file
System.Diagnostics.Process.Start(output)
End Sub
End Class
End Namespace
Everytime we try to open a password-protected PowerPoint file, we will then be prompted to enter the password. This can be really a bothering thing itself. But things get worse if we forget the password. To avoid this situation from being occurred, we can choose to remove the encryption if the PowerPoint file is not necessarily protected. In this article, I’ll introduce you how to remove encryption on password-protected PowerPoint file using Spire.Presentation.
In the classes of Spire.Presentation, you can invoke Presentation.LoadFromFile(string file, string password) method to load the file that you want to remove protection, then you're entitled to remove encryption by calling Presentation.RemoveEncryption() method. More details:
Step 1: Create Presentation instance and load file.
Presentation presentation = new Presentation();
presentation.LoadFromFile("Presentation1.pptx", "test");
Step 2: Remove encryption.
presentation.RemoveEncryption();
Step 3: Save and launch the file.
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
Effect Screenshot:

Full Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
namespace RemoveProtect
{
class Program
{
static void Main(string[] args)
{
// create Presentation instance and load file
Presentation presentation = new Presentation();
presentation.LoadFromFile("Presentation1.pptx", "test");
//remove encryption
presentation.RemoveEncryption();
//save the file
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Presentation
Namespace RemoveProtect
Class Program
Shared Sub Main(ByVal args() As String)
' create Presentation instance and load file
Dim presentation As Presentation = New Presentation()
presentation.LoadFromFile("Presentation1.pptx", "test")
'remove encryption
presentation.RemoveEncryption()
'save the file
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("result.pptx")
End Sub
End Class
End Namespace
A table, as a great way to present data into groups, always plays an important role in any type of electronic documents. A well formatted table must contains larger or smaller cells without influencing the entire row or colum - and that's something that can be easily achieved by merging or splitting cells in your existing table.
In the next section, we will introduce you how to merge cells on en existing table which is embedded on a PowerPoint slide using Spire.Presentation for .NET. By convention, we need to download and install Spire.Presentation first, add its dll as a reference in you Visual C# or VB.NET project.
Assume you got a sample PPT file which contains a table like this, obviously you can merge cell 2 and cell 3 in the first column to display the account information more clearly.

How to achieve this programmatically using Spire.Presentation?
Step 1: Create a PPT document and load the sample file.
Presentation presentation = new Presentation();
presentation.LoadFromFile("table.pptx");
Step 2: Get the table and merge the second row and third row of the first column.
ITable table = null;
foreach (IShape shape in presentation.Slides[0].Shapes)
{
if (shape is ITable)
{
table = (ITable)shape;
table.MergeCells(table[0, 1], table[0, 2], false);
}
}
Step 3: Save and launch the file.
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
Result:

Full code:
using Spire.Presentation;
namespace MergeCells
{
class Program
{
static void Main(string[] args)
{
// create a PPT document and load file
Presentation presentation = new Presentation();
presentation.LoadFromFile("table.pptx");
// get the table in PPT document
ITable table = null;
foreach (IShape shape in presentation.Slides[0].Shapes)
{
if (shape is ITable)
{
table = (ITable)shape;
//merge the second row and third row of the first column
table.MergeCells(table[0, 1], table[0, 2], false);
}
}
// save the document
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
Imports Spire.Presentation
Namespace MergeCells
Class Program
Private Shared Sub Main(args As String())
' create a PPT document and load file
Dim presentation As New Presentation()
presentation.LoadFromFile("table.pptx")
' get the table in PPT document
Dim table As ITable = Nothing
For Each shape As IShape In presentation.Slides(0).Shapes
If TypeOf shape Is ITable Then
table = DirectCast(shape, ITable)
'merge the second row and third row of the first column
table.MergeCells(table(0, 1), table(0, 2), False)
End If
Next
' save the document
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("result.pptx")
End Sub
End Class
End Namespace