操作 PowerPoint 文档中的表格,包括获取表格信息,添加、删除表格,合并、拆分单元格,设置表格行高列宽等。
接口方法 1:getSlideTable() 获取表格信息
HTTP 请求方法:GET
请求 URL:https://api.e-iceblue.cn/v1/powerpoint/{name}/slides/{slideIndex}/shape/{shapeIndex}/table
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class getSlideTable {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.getSlideTable(name, slideIndex, shapeIndex, password, folder, storage);
}
}
接口方法 2:deleteSlideTable() 删除幻灯片中的表格
HTTP 请求方法:DELETE
请求 URL:https://api.e-iceblue.cn/v1/powerpoint/{name}/slides/{slideIndex}/shape/{shapeIndex}/table
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
public class deleteSlideTable {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
String password = null;
String folder = "input";
String storage = null;
tableApi.deleteSlideTable(name, slideIndex, shapeIndex, password, folder, storage);
}
}
接口方法 3:addSlideTable() 在幻灯片中添加表格
HTTP 请求方法:POST
请求 URL:https://api.e-iceblue.cn/v1/powerpoint /{name}/slides/{slideIndex}/table
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
x | 是 | number | X坐标 | |
y | 是 | number | Y坐标 | |
heights | 是 | string | 逗号分隔的单元格高度数组 | |
widths | 是 | string | 逗号分隔的单元格宽度数组 | |
tableData | 是 | string | 包含表格数据的二维数组 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class addSlideTable {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 1;
double x = 0;
double y = 0;
String heights = "[50,50,50,50]";
String widths = "[150,150,150,150]";
String tableData = "[" +
"[11,12,13,14]," +
"[21,22,23,24]," +
"[31,32,33,34]," +
"[41,42,43,44]" +
"]";
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.addSlideTable(name, slideIndex, x, y, heights, widths, tableData, password, folder, storage);
}
}
接口方法 4:setSlideTableCellFormat() 设置单元格格式
HTTP 请求方法:PUT
请求 URL:https://api.e-iceblue.cn/v1/powerpoint/{name}/slides/{slideIndex}/shape/{shapeIndex}/table/tableCell
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
source | 否 | object | { "Text": "string", "RowSpan": 0, "ColSpan": 0, "MarginTop": 0, "MarginRight": 0, "MarginLeft": 0, "MarginBottom": 0, "TextAnchorType": "string", "TextVerticalType": "string", "FillFormat": {}, "BorderTop": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "BorderRight": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "BorderLeft": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "BorderBottom": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "BorderDiagonalUp": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "BorderDiagonalDown": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 } } | 设置单元格的数据 |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class setSlideTableCellFormat {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
TableCell source = new TableCell();
source.setText("");
source.setRowSpan(1);
source.setColSpan(1);
source.setMarginTop(1d);
source.setMarginRight(1d);
source.setMarginLeft(3.6d);
source.setMarginBottom(3.6d);
source.setTextAnchorType("Center");
source.setTextVerticalType("Horizontal");
source.setFillFormat(new SolidFill("lightpink"));
source.setBorderDiagonalDown(null);
source.setBorderDiagonalUp(null);
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.setSlideTableCellFormat(name, slideIndex, shapeIndex, source, password, folder, storage);
}
}
接口方法 5:mergeSlideTableCell() 合并单元格
HTTP 请求方法:PUT
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
path | 是 | string | 包含两个坐标的二维数组 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class mergeSlideTableCell {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
String path = "[[1,2],[2,3]]";
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.mergeSlideTableCell(name, slideIndex, shapeIndex, path, password, folder, storage);
}
}
接口方法 6:splitSlideTableCell() 拆分单元格
HTTP 请求方法:PUT
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
path | 是 | string | 包含两个坐标的二维数组 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class splitSlideTableCell {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
String path = "[[1,2],[2,3]]";
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.splitSlideTableCell(name, slideIndex, shapeIndex, path, password, folder, storage);
}
}
接口方法 7:setSlideTableCellTextFormat() 设置单元格中的文本格式
HTTP 请求方法:PUT
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
path | 是 | string | 单元格坐标 | |
source | 否 | object | { "SelfUri": { "Href": "string", "Relation": "string", "LinkType": "string", "Title": "string" }, "AlternateLinks": [ { "Href": "string", "Relation": "string", "LinkType": "string", "Title": "string" } ], "Text": "string", "FontBold": true, "FontItalic": true, "FontUnderline": "None", "StrikethroughType": "None", "TextCapType": "None", "Escapement": 0, "Spacing": 0, "FontColor": "string", "HighlightColor": "string", "FontHeight": 0, "NormaliseHeight": true, "ProofDisabled": true, "SmartTagClean": true, "KerningMinimalSize": 0, "Kumimoji": true, "LanguageId": "string", "AlternativeLanguageId": "string", "IsHardUnderlineFill": true, "IsHardUnderlineLine": true, "FillFormat": {}, "EffectFormat": { "Blur": { "Radius": 0, "Grow": true }, "Glow": { "Radius": 0, "Color": "string" }, "InnerShadow": { "Direction": 0, "Distance": 0, "BlurRadius": 0, "ShadowColor": "string" }, "OuterShadow": { "Direction": 0, "Distance": 0, "BlurRadius": 0, "ShadowColor": "string" }, "PresetShadow": { "Direction": 0, "Distance": 0, "Preset": "TopLeftDrop", "ShadowColor": "string" }, "SoftEdge": { "Radius": 0 }, "Reflection": { "Direction": 0, "FadeDirection": 0, "Distance": 0, "BlurRadius": 0, "ScaleHorizontal": 0, "ScaleVertical": 0, "SkewHorizontal": 0, "SkewVertical": 0, "StartPosAlpha": 0, "EndPosAlpha": 0, "StartReflectionOpacity": 0, "EndReflectionOpacity": 0, "RectangleAlign": "None", "RotateShadowWithShape": true }, "FillOverlay": { "Blend": "Darken" } }, "LineFormat": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 }, "UnderlineFillFormat": {}, "UnderlineLineFormat": { "Alignment": "None", "CapStyle": "None", "DashStyle": "None", "JoinStyle": "None", "Style": "None", "BeginArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "EndArrowHead": { "Length": "None", "Style": "UnDefined", "Width": "None" }, "CustomDashPattern": { "Items": [ 0 ] }, "FillFormat": {}, "MiterLimit": 0, "Width": 0 } } | 单元格部分的数据传输对象 |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class setSlideTableCellTextFormat {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
String path = "[0,0]";
Portion source = new Portion();
source.setText("12345678");
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.setSlideTableCellTextFormat(name, slideIndex, shapeIndex, path, password, source, folder, storage);
}
}
接口方法 8:setSlideTableRowHeight() 设置表格行高
HTTP 请求方法:PUT
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
rowIndex | 是 | integer | 行的索引 | |
height | 是 | number | 行高 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class setSlideTableRowHeight {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
Integer rowIndex = 0;
double height = 70;
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.setSlideTableRowHeight(name, slideIndex, shapeIndex, rowIndex, height, password, folder, storage);
}
}
接口方法 9:setSlideTableColumnWidth() 设置表格列宽
HTTP 请求方法:PUT
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
slideIndex | 是 | integer | 幻灯片索引 | |
shapeIndex | 是 | string | 形状索引或形状组的索引 | |
columnIndex | 是 | integer | 列的索引 | |
width | 是 | number | 列宽 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null |
Java 代码示例:
import spire.cloud.powerpoint.sdk.*;
import spire.cloud.powerpoint.sdk.api.TableApi;
import spire.cloud.powerpoint.sdk.model.*;
public class setSlideTableColumnWidth {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration configuration = new Configuration(appId, appKey,baseUrl);
static TableApi tableApi = new TableApi(configuration);
public static void main(String[] args) throws ApiException {
String name = "template.pptx";
Integer slideIndex = 0;
String shapeIndex = "0";
Integer columnIndex = 0;
double width = 200;
String password = null;
String folder = "input";
String storage = null;
Table response = tableApi.setSlideTableColumnWidth(name, slideIndex, shapeIndex, columnIndex, width, password, folder, storage);
}
}