操作Word文档中的段落,包括获取段落,添加段落,更新段落,删除段落等。
接口方法1:getParagraphs()获取段落
HTTP请求方法:GET
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/paragraphs
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 否 | string | 段落的路径,如果省略此参数,则其默认值为文档根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetParagraphs
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
string fileName = "getParagraphs.docx";
string name = fileName;
string folder = "input";
string storage = null;
string password = null;
string nodePath = null;
var response = paragraphsApi.GetParagraphs(name, folder, storage, password, nodePath);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
import spire.cloud.word.sdk.client.model.*;
import java.util.List;
public class GetParagraphs {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "getParagraphs.docx";
String name = fileName;
String folder = "input";
String storage = null;
String password = null;
String nodePath = null;
List<ObjectInfo> response = paragraphsApi.getParagraphs(name, folder, storage, password, nodePath);
}
}
接口方法2:addParagraph()添加段落
HTTP请求方法:POST
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 否 | string | 段落的路径,如果省略此参数,则其默认值为文档根目录 | |
indexOfParagraph | 否 | string | 用于插入段落的索引 | |
text | 否 | string | 插入段落的文字 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace AddParagraph
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "addParagraph.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int indexOfParagraph = 1;
string folder = "input";
string password = null;
string text = "E-iceblue";
string destFilePath = "output/AddParagraph_output.docx";
string storage = null;
paragraphsApi.AddParagraph(name, nodePath, destFilePath, folder, storage, indexOfParagraph, password, text);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
public class AddParagraph {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "addParagraph.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer indexOfParagraph = 1;
String folder = "input";
String password = null;
String text = "E-iceblue";
String destFilePath = "output/AddParagraph_output.docx";
String storage = null;
paragraphsApi.addParagraph(name, nodePath, destFilePath, folder, storage, indexOfParagraph, password, text);
}
}
接口方法3: deleteParagraph()删除段落
HTTP请求方法:DELETE
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs/{index}
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 否 | string | 段落的路径,如果省略此参数,则其默认值为文档根目录 | |
index | 是 | integer | 被删除段落的索引 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace DeleteParagraph
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "deleteParagraph.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int index = 0;
string folder = "input";
string password = null;
string storage = null;
string destFilePath = "output/DeleteParagraph_output.docx";
paragraphsApi.DeleteParagraph(name, nodePath, index, destFilePath, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
public class DeleteParagraph {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "deleteParagraph.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer index = 0;
String folder = "input";
String password = null;
String storage = null;
String destFilePath = "output/DeleteParagraph_output.docx";
paragraphsApi.deleteParagraph(name, nodePath, index, destFilePath, folder, storage, password);
}
}
接口方法4:getParagraphChildObjects()获取段落子对象
HTTP请求方法:GET
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs/{index}/childObjects
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 是 | string | 段落的路径 | |
index | 是 | integer | 段落的索引 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetParagraphChildObjects
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "getParaChildObjects.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int index = 0;
string folder = "input";
string storage = null;
string password = null;
var response = paragraphsApi.GetParagraphChildObjects(name, nodePath, index, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
import spire.cloud.word.sdk.client.model.ObjectInfo;
import java.util.List;
public class GetParagraphChildObjects {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "getParaChildObjects.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer index = 0;
String folder = "input";
String storage = null;
String password = null;
List<ObjectInfo> response = paragraphsApi.getParagraphChildObjects(name, nodePath, index, folder, storage,password);
}
}
接口方法5:getParagraphFormat()获取段落样式
HTTP 请求方法:GET
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs/{index}/format
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 是 | string | 段落的路径 | |
index | 是 | integer | 段落的索引 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetParagraphFormat
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "getParagraphformat.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int index = 0;
string folder = "input";
string storage = null;
string password = null;
var response = paragraphsApi.GetParagraphFormat(name, nodePath, index, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
import spire.cloud.word.sdk.client.model.ParagraphFormat;
public class GetParagraphFormat {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "getParagraphformat.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer index = 0;
String folder = "input";
String storage = null;
String password = null;
ParagraphFormat response = paragraphsApi.getParagraphFormat(name, nodePath, index, folder, storage,password);
}
}
接口方法6:updataParagraphFormat()更新段落样式
HTTP 请求方法:PUT
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs/{index}/format
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 是 | string | 段落的路径 | |
index | 是 | integer | 段落的索引 | |
format | 是 | object | { "horizontalAlignment": "Left", "leftOrInnerIndent": 0, "rightOrOutsideIndent": 0, "mirrorIndents": true, "firstLineIndent": 0, "backgroundColor": { "red": 0, "green": 0, "blue": 0 }, "beforeSpacing": 0, "afterSpacing": 0, "beforeAutoSpacing": true, "afterAutoSpacing": true, "lineSpace": 0, "lineSpacingRule": "AtLeast", "wordWrap": true, "borders": { "topBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 }, "bottomBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 }, "leftBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 }, "rightBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 }, "horizontalBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 }, "verticalBorder": { "borderType": "None", "color": { "red": 0, "green": 0, "blue": 0 }, "shadow": true, "lineWidth": 0, "space": 0 } } } | 段落格式 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
namespace UpdateParagraphFormat
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "updateParagraphFormat.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int index = 0;
string folder = "input";
string storage = null;
string password = null;
ParagraphFormat format = new ParagraphFormat
{
HorizontalAlignment = ParagraphFormat.HorizontalAlignmentEnum.Distribute,
LeftOrInnerIndent = 20,
RightOrOutsideIndent = 10,
MirrorIndents = false,
FirstLineIndent = 30,
BackgroundColor = new Color(0, 200, 200),
BeforeSpacing = 40,
AfterSpacing = 40,
BeforeAutoSpacing = false,
AfterAutoSpacing = false,
LineSpace = 50,
LineSpacingRule = ParagraphFormat.LineSpacingRuleEnum.Exactly,
WordWrap = true,
Borders = new Borders(
new Border(
Border.BorderTypeEnum.Double,
new Color(255, 10, 10),
true,
2))
};
string destFilePath = "output/UpdateParagraphFormat_output.docx";
paragraphsApi.UpdateParagraphFormat(name, nodePath, index, format, destFilePath, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
import spire.cloud.word.sdk.client.model.*;
public class AddParagraph {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "updateParagraphFormat.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer index = 0;
String folder = "input";
String storage = null;
String password = null;
ParagraphFormat format = new ParagraphFormat();
format.setHorizontalAlignment(ParagraphFormat.HorizontalAlignmentEnum.DISTRIBUTE);
format.setLeftOrInnerIndent(20f);
format.setRightOrOutsideIndent(10f);
format.setMirrorIndents(false);
format.setFirstLineIndent(30f);
format.setBackgroundColor( new Color(0, 200, 200));
format.setBeforeSpacing(40f);
format.setAfterSpacing(40f);
format.setBeforeAutoSpacing(false);
format.setBeforeAutoSpacing(false);
format.setLineSpace(50f);
format.setLineSpacingRule( ParagraphFormat.LineSpacingRuleEnum.EXACTLY);
format.setWordWrap(true);
Border topBorder = new Border();
topBorder.setBorderType(Border.BorderTypeEnum.DOUBLE);
Borders borders = new Borders();
borders.setTopBorder(topBorder);
format.setBorders(borders);
String destFilePath = "output/UpdateParagraphFormat_output.docx";
paragraphsApi.updateParagraphFormat(name, nodePath, index, format, destFilePath,folder, storage, password );
}
}
接口方法7:updateParagraphText()更新段落文本
HTTP 请求方法:PUT
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{nodePath}/paragraphs/{index}/text
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
nodePath | 是 | string | 段落的路径 | |
index | 是 | string | 段落的索引 | |
text | 是 | string | 更新后的段落文本 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace UpdateParagraphText
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static string baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
static void Main(string[] args)
{
var fileName = "updateParagraphText.docx";
string name = fileName;
string nodePath = "Section/0/Body/0";
int index = 0;
string text = "E-iceblue";
string folder = "input";
string password = null;
string storage = null;
string destFilePath = "output/UpdateParagraphText_output.docx";
paragraphsApi.UpdateParagraphText(name, nodePath, index, text, destFilePath, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ParagraphsApi;
public class UpdateParagraphText {
static String appId = "your id";
static String appKey = "your key";
static String baseUrl = "https://api.e-iceblue.cn";
static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
static ParagraphsApi paragraphsApi = new ParagraphsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String fileName = "updateParagraphText.docx";
String name = fileName;
String nodePath = "Section/0/Body/0";
Integer index = 0;
String text = "E-iceblue";
String folder = "input";
String password = null;
String storage = null;
String destFilePath = "output/UpdateParagraphText_output.docx";
paragraphsApi.updateParagraphText(name, nodePath, index, text, destFilePath,folder, storage, password);
}
}