Spire.Cloud.PowerPoint offers the TableApi interface to create, manipulate and delete tables in a PowerPoint document. This article will introduce how to use the interface to create a table.
import spire.cloud.powerpoint.sdk.ApiException;
import spire.cloud.powerpoint.sdk.Configuration;
import spire.cloud.powerpoint.sdk.api.TableApi;
public class CreateTable {
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
public static void main(String[] args) throws ApiException {
//Create a Configuration object based on your App ID and App Key
Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a tableApi instance
TableApi tableApi = new TableApi(configuration);
//load a PowerPoint sample
String name = "Sample.pptx";
//Specify the password used to open the sample, it's null if nothing
String password = null;
//Specify the folder storing the sample, it’s null if nothing
String folder = "input";
//Use the 2G storage provided by E-iceblue Cloud, it’s null by default
String storage = null;
//Specify the slide which needs to add a table
Integer slideIndex = 1;
//The value of x coordinate where a table will be inserted
double x = 100;
//The value of y coordinate where a table will be inserted
double y = 100;
//The row height of the table
String heights = "[30,30,30,30]";
//The column width of the table
String widths = "[100,100,100,100]";
//Add data into the table
String tableData = "[" +
"[No.,Name,Age,Gender]," +
"[1,Tom,23,Male]," +
"[2,Jerry,33,Male]," +
"[3,Cherry,43,Female]" +
"]";
//Call the addSlideTable method to create a table in a PowerPoint slide
tableApi.addSlideTable(name, slideIndex, x, y, heights, widths, tableData, password, folder, storage);
}
}