Spire.Cloud.PowerPoint provides the TableApi interface to handle tables in PowerPoint documents. This article shows you how to add a table to a slide by using this API.
using Spire.Cloud.Powerpoint.Sdk.Client;
using Spire.Cloud.Powerpoint.Sdk.Api;
namespace CreateTable
{
class Program
{
static string appId = "App ID";
static string appKey = "App Key";
static string baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration object based on App ID and App Key
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a TableApi object
static TableApi tableApi = new TableApi(configuration);
static void Main(string[] args)
{
//Specify the source document name
string name = "template.pptx";
//Specify the slide index
int? slideIndex = 1;
//Specify the x and y coordinate where the table will be added
double? x = 100;
double? y = 100;
//Specify the row height and column width
string heights = "[30,30,30,30]";
string widths = "[100,100,100,100]";
//Specify the table data
string tableData = "[" +
"[Name,Sex,Age,ID]," +
"[Winny,Female,23,0109]," +
"[Moon,Male,33,0111]," +
"[Lois,Female,28,0112]" +
"]";
//Specify the original password, set to null if there is no password
string password = null;
//Specify the folder where the source document is stored
string folder = "input";
//Use the default storage, set to null
string storage = null;
//Call AddSlideTable method to add table to the specified slide
tableApi.AddSlideTable(name, slideIndex, x, y, heights, widths, tableData, password, folder, storage);
}
}
}