With the help of Spire.Presentation, we can easily set the border type and color of a whole table on the presentation slides. This article will focus on demonstrating how to set the border for the table in C#.
Firstly, view the 12 border types for the table on PowerPoint file:
How to set the border type and color for an existing table on presentation slide:
//create a presentation document and load the file from disk Presentation presentation = new Presentation(); presentation.LoadFromFile("Sample.pptx"); //get the table from the first slide of the sample document ISlide slide = presentation.Slides[0]; ITable table = slide.Shapes[1] as ITable; //set the border type as Inside and the border color as blue table.SetTableBorder(TableBorderType.Inside, 1, Color.Blue); //save the document to file presentation.SaveToFile("Insideborder.pptx", FileFormat.Pptx2010);
Effective screenshot after set the border type for an existing table on presentation slide:
How to set the border type and color for newly added tables on presentation slide:
using Spire.Presentation; using System; namespace Set_border_type_and_color { class Program { static void Main(string[] args) { //create a presentation document Presentation presentation = new Presentation(); //set the table width and height for each table cell double[] tableWidth = new double[] { 100, 100, 100, 100, 100 }; double[] tableHeight = new double[] { 20, 20 }; //traverse all the border type of the table foreach (TableBorderType item in Enum.GetValues(typeof(TableBorderType))) //add a table to the presentation slide with the setting width and height { ITable itable = presentation.Slides.Append().Shapes.AppendTable(100, 100, tableWidth, tableHeight); //add some text to the table cell itable.TableRows[0][0].TextFrame.Text = "Row"; itable.TableRows[1][0].TextFrame.Text = "Column"; //set the border type, border width and the border color for the table itable.SetTableBorder(item, 1.5, Color.Red); } //save the document to file presentation.SaveToFile("Addtablewithborder.pptx", FileFormat.Pptx2010); } } }