Knowledgebase (2330)
Children categories
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
How to Expand/Collapse the rows in an existing Pivot Table in C#
2014-07-25 02:52:19 Written by AdministratorPivot table displays the data in sort, count total or give the average of the data stored in one table or spreadsheet. So it gives readers clear information of the data's trends and patterns rather than a large amount of similar data. Sometimes, there are so many rows in one pivot table and we may need to expand or collapse them to make the pivot table more clearly.
By using Spire.XLS for .NET, developers can create pivot table. This article will show you how to expand and collapse the rows in an existing Pivot table in C#.
Firstly, make sure that Spire.XLS for .NET (version7.5.5 or above) has been installed on your machine. And then, adds Spire.XLS.dll as reference in the downloaded Bin folder thought the below path: "..\Spire.XLS\Bin\NET4.0\ Spire.XLS.dll".
//Create a new excel document
Workbook book = new Workbook();
//load an excel document with Pivot table from the file
book.LoadFromFile("test.xlsx");
//Find the Pivot Table sheet
Worksheet sheet = book.Worksheets["Pivot Table"];
//Get the data in Pivot Table
Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotTable pivotTable = sheet.PivotTables[0] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotTable;
//Calculate Data
pivotTable.CalculateData();
//Collapse the rows
(pivotTable.PivotFields["Vendor No"] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotField).HideItemDetail("1501", true);
//Expand the rows
(pivotTable.PivotFields["Vendor No"] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotField).HideItemDetail("1502", false);
//Save the document to file
book.SaveToFile("result.xlsx", ExcelVersion.Version2007);
Effective screenshots:
Collapse the rows in Pivot table in C#

Expand the rows in Pivot table in C#

Full codes:
using Spire.Xls;
namespace HighlightValues
{
class Program
{
static void Main(string[] args)
{
Workbook book = new Workbook();
book.LoadFromFile("test.xlsx");
Worksheet sheet = book.Worksheets["Pivot Table"];
Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotTable pivotTable = sheet.PivotTables[0] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotTable;
pivotTable.CalculateData();
(pivotTable.PivotFields["Vendor No"] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotField).HideItemDetail("1501", true);
(pivotTable.PivotFields["Vendor No"] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotField).HideItemDetail("1502", true);
book.SaveToFile("result_1.xlsx", ExcelVersion.Version2007);
(pivotTable.PivotFields["Vendor No"] as Spire.Xls.Core.Spreadsheet.PivotTables.XlsPivotField).HideItemDetail("1502", false);
book.SaveToFile("result_2.xlsx", ExcelVersion.Version2007);
}
}
}