Home  >  Article  >  Backend Development  >  C# uses Free Spire.Presentation to insert and edit PPT and delete tables

C# uses Free Spire.Presentation to insert and edit PPT and delete tables

黄舟
黄舟Original
2017-10-01 07:24:573110browse

The editor found that using the .NET component - Free Spire.Presentation, adding the product DLL file in C# can easily and quickly implement operations such as table insertion, editing and deletion of presentations. Please refer to the specific implementation code below. Article Bar

In modern study and office, we are often exposed to the use of forms, such as various documents, statements, accounts, etc. It is also inevitable to apply various data tables in PPT presentations. For inserting tables into PPT, I found a new method, but I used a free .NET component-Free Spire.Presentation. Adding the product DLL file in C# can easily and quickly implement presentations. Table insertion, editing and deletion operations. If necessary, you can download it at the following URL: https://www.e-iceblue.cn/Downloads/Free-Spire-Presentation-NET.html

1. Insert table

Step 1: Create a PowerPoint document


  Presentation ppt = new Presentation();
   ppt.SlideSize.Type = SlideSizeType.Screen16x9;

Step 2: Initialize an ITable instance and specify the position, number of rows and columns number, row height and column width                                                                                                                                                                                                     ​Declare and initialize a String[,] array                                                                                                                                                                 The following PPT document effect


2. Delete table rows and columns

Step 1: Initialize a Presentation Instance and load a PowerPoint document


double[] widths = new double[] { 100, 100, 100, 100, 100 };
   double[] heights = new double[] { 15, 15, 15, 15, 15 };
   ITable table = ppt.Slides[0].Shapes.AppendTable(80, 80, widths, heights);

Step 2: Get the table on the first slide


 table.StylePreset = TableStylePreset.LightStyle1Accent2;

Steps Three: Delete the fourth column and fourth row                                                                                                                                                                              

3. Delete the table

Step 1: Initialize a Presentation instance and load a PowerPoint document​​​​​


 string[,] data = new string[,]
{
   {"排名","姓名", "销售额","回款额","工号"},
   {"1","李彪","18270","18270","0011"},
   {"2","李娜","18105","18105","0025"},
   {"3","张丽","17987","17987","0008"},
   {"4","黄艳","17790","17790","0017"},
};

Step 2: Initialize a List object, the element type is IShape                                                                           table graphic and add it to the List                                                                                                                                                                                          ​#Step 5: Save the document


 ppt.SaveToFile("创建表格.pptx", FileFormat.Pptx2010);

Summary

The above is the detailed content of C# uses Free Spire.Presentation to insert and edit PPT and delete tables. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn