处理 Word 文档中的域,包括返回指定文档中的域,更新域,添加域,删除域等操作。
接口方法 1:getFields() 获取文档中域
HTTP 请求方法:GET
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/fields
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
paragraphPath | 否 | string | 含有域的段落路径,如果省略该参数,则默认为文档的根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetFields
{
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
static void Main(string[] args)
{
string name = "getFields.docx";
string folder = "input";
string storage = null;
string password = null;
string paragraphPath = null;
var response = fieldsApi.GetFields(name, folder, storage, password, paragraphPath);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.FieldsApi;
import spire.cloud.word.sdk.client.model.ObjectInfo;
import java.util.List;
public class GetFields {
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "getFields.docx";
String folder = "input";
String storage = null;
String password = null;
String paragraphPath = null;
List<ObjectInfo> response = fieldsApi.getFields(name, folder, storage, password, paragraphPath);
}
}
接口方法 2:getFields() 获取文档中域
HTTP 请求方法:PUT
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/fields
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace UpdateField
{
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
static void Main(string[] args)
{
string name = "updateField.docx";
string folder = "input";
string storage = null;
string password = null;
string destFilePath = "output/updateField_output.docx";
fieldsApi.UpdateField(name, folder, storage, password, destFilePath);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.FieldsApi;
public class UpdateField {
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "updateField.docx";
String folder = "input";
String storage = null;
String password = null;
String destFilePath = "output/updateField_output.docx";
fieldsApi.updateField(name, folder, storage, password, destFilePath);
}
}
接口方法 3:addField() 添加域
HTTP 请求方法:POST
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/{paragraphPath}/fields
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 | |
paragraphPath | 是 | string | 含有域的段落路径,如果省略该参数,则默认为文档的根目录 | |
indexInParagraph | 否 | integer | 添加域的段落的索引 | |
fieldCode | 是 | string | 域代码 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace AddField
{
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
static void Main(string[] args)
{
string name = "addField.docx";
string paragraphPath = "Section/0/Body/0/Paragraph/0";
string fieldCode = "DATE \\@ \"h时m分s秒\"";
string folder = "input";
string storage = null;
string password = null;
int? indexInParagraph = 0;
string destFilePath = "output/addField_output.docx";
fieldsApi.AddField(name, paragraphPath, fieldCode, destFilePath, folder, storage, password, indexInParagraph);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.FieldsApi;
public class AddField {
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "addField.docx";
String paragraphPath = "Section/0/Body/0/Paragraph/0";
String fieldCode = "DATE \\@ \"h时m分s秒\"";
String folder = "input";
String storage = null;
String password = null;
Integer indexInParagraph = 0;
String destFilePath = "output/addField_output.docx";
fieldsApi.addField(name, paragraphPath, fieldCode, destFilePath, folder, storage, password, indexInParagraph);
}
}
接口方法 4:deleteField() 删除域
HTTP 请求方法:DELETE
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/{paragraphPath}/fields/{index}
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 | |
paragraphPath | 是 | string | 含有域的段落路径,如果省略该参数,则默认为文档的根目录 | |
index | 否 | integer | 特定域的索引 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace DeleteField
{
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
static void Main(string[] args)
{
string name = "deleteField.docx";
string paragraphPath = "Section/0/Body/0/Paragraph/0";
int index = 0;
string folder = "input";
string storage = null;
string password = null;
string destFilePath = "output/deleteField_output.docx";
fieldsApi.DeleteField(name, paragraphPath, index, destFilePath, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.FieldsApi;
public class DeleteField {
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "deleteField.docx";
String paragraphPath = "Section/0/Body/0/Paragraph/0";
Integer index = 0;
String folder = "input";
String storage = null;
String password = null;
String destFilePath = "output/deleteField_output.docx";
fieldsApi.deleteField(name, paragraphPath, index, destFilePath, folder, storage, password);
}
}
接口方法 5:addMergeField() 添加合并域
HTTP 请求方法:POST
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/{paragraphPath}/mergeField
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 | |
paragraphPath | 是 | string | 含有域的段落路径,如果省略该参数,则默认为文档的根目录 | |
indexInParagraph | 否 | integer | 添加域的段落的索引 | |
fieldName | 是 | string | 域的名称 | |
fieldCode | 否 | string | 域代码 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace AddMergeField
{
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
static void Main(string[] args)
{
string name = "addMergeField.docx";
string paragraphPath = "Section/0/Body/0/Paragraph/0";
string fieldName = "FiledTest";
string folder = "input";
string storage = null;
string password = null;
int indexInParagraph = 0;
string fieldCode = null;
string destFilePath = "output/addMergeField_output.docx";
fieldsApi.AddMergeField(name, paragraphPath, fieldName, destFilePath, folder, storage, password, indexInParagraph, fieldCode);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.FieldsApi;
public class AddMergeField {
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 FieldsApi fieldsApi = new FieldsApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "addMergeField.docx";
String paragraphPath = "Section/0/Body/0/Paragraph/0";
String fieldName = "FiledTest";
String folder = "input";
String storage = null;
String password = null;
Integer indexInParagraph = 0;
String fieldCode = null;
String destFilePath = "output/addMergeField_output.docx";
fieldsApi.addMergeField(name, paragraphPath, fieldName, destFilePath, folder, storage, password, indexInParagraph, fieldCode);
}
}