Sections 接口描述

 

操作Word文档中的节,包括获取节,添加节,获取节的子对象等。

接口方法1:getSections()获取文档中的节并返回List

HTTP请求方法:GET

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/sections

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace GetSections
{
    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "template.docx"; ;
            string folder = "input";
            string storage = null;
            string password = null;
            var response = sectionsApi.GetSections(name, folder, storage, password);
        }
    }
}

	
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.SectionsApi;
import spire.cloud.word.sdk.client.model.*;
import java.util.List;

public class GetSections {

    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
    
    public static void main(String[] args) throws ApiException {

        String name = "template.docx"; ;
        String folder = "input";
        String storage = null;
        String password = null;
        List<ObjectInfo>  response = sectionsApi.getSections(name, folder, storage, password);
    }
}

接口方法2:addSection() 添加节

HTTP请求方法:POST

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/sections

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
sectionIndex integer 节的索引
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace AddSection
{
    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "template.docx";
            string folder = "input";
            string storage = null;
            string password = null;
            int? sectionIndex = null;
            string destFilePath = "output/addSection_output.docx";
            sectionsApi.AddSection(name, destFilePath, folder, storage, password, sectionIndex);
        }
    }
}

	
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.SectionsApi;

public class AddSection {

    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "template.docx";
        String folder = "input";
        String storage = null;
        String password = null;
        Integer  sectionIndex = null;
        String destFilePath = "output/addSection_output.docx";
        sectionsApi.addSection(name, destFilePath, folder, storage, password, sectionIndex);
    }
}

接口方法3:getSectionChildObjects() 获取节的子对象

HTTP请求方法:GET

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{sectionIndex}/childObjects

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
sectionIndex integer 节的索引

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace GetSectionChildObjects
{
    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "getSectionChildObjects.docx"; ;
            int sectionIndex = 0;
            string folder = "input";
            string storage = null;
            string password = null;
            var response = sectionsApi.GetSectionChildObjects(name, sectionIndex, folder, storage, password);
        }
    }
}

	
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.SectionsApi;
import spire.cloud.word.sdk.client.model.*;
import java.util.List;

public class GetSectionChildObjects {

    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "getSectionChildObjects.docx"; ;
        Integer  sectionIndex = 0;
        String folder = "input";
        String storage = null;
        String password = null;
        List<ObjectInfo> response = sectionsApi.getSectionChildObjects(name, sectionIndex, folder, storage, password);
    }
}

接口方法4:getPageSetup() 获取节的PageSetup

HTTP请求方法:GET

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{sectionIndex}/pageSetup

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
sectionIndex integer 节的索引

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace GetPageSetup
{
    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "getPageSetup.docx";
            int? sectionIndex = 0;
            string folder = "input";
            string storage = null;
            string password = null;
            var response = sectionsApi.GetPageSetup(name, sectionIndex, folder, storage, password);
        }
    }
}

	
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.SectionsApi;
import spire.cloud.word.sdk.client.model.*;

public class GetPageSetup {

    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "getPageSetup.docx";
        Integer  sectionIndex = 0;
        String folder = "input";
        String storage = null;
        String password = null;
        PageSetup response = sectionsApi.getPageSetup(name, sectionIndex, folder, storage, password);
    }
}

接口方法5:updatePageSetup() 更新节的PageSetup

HTTP请求方法:PUT

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/{sectionIndex}/pageSetup

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
sectionIndex integer 节的索引
pageSetUp object { "pageWidth": 0, "pageHeight": 0, "pageMargin": { "top": 0, "bottom": 0, "left": 0, "right": 0 }, "orientation": "Portrait", "linenumber": { "startValue": 0, "step": 0, "restartMode": "RestartPage", "distanceFromText": 0 } } PageSetup对象
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;

namespace UpdatePageSetup
{
    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "updatePageSetup.docx"; ;
            int? sectionIndex = 0;
            string storage = null;
            var marging = new Margin(20, 20, 20, 20);
            var linenumber = new LineNumber(1, 2, LineNumber.RestartModeEnum.Continuous, 20);
            PageSetup pageSetup = new PageSetup(400, 500, marging, PageSetup.OrientationEnum.Landscape, linenumber);
            string folder = "input";
            string password = null;
            string destFilePath = "output/updatePageSetup_output.docx";
            sectionsApi.UpdatePageSetup(name, sectionIndex, pageSetup, destFilePath, folder, storage, password);
        }
    }
}

	
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.SectionsApi;
import spire.cloud.word.sdk.client.model.*;

public class UpdatePageSetup {

    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 SectionsApi sectionsApi = new SectionsApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "updatePageSetup.docx"; ;
        Integer  sectionIndex = 0;
        String storage = null;
        Margin marging = new Margin();
        marging.setTop(20f);
        marging.setBottom(20f);
        marging.setLeft(20f);
        marging.setRight(20f);
        LineNumber linenumber = new LineNumber(1, 2);
        linenumber.setRestartMode(LineNumber.RestartModeEnum.CONTINUOUS);
        linenumber.setDistanceFromText(20f);
        PageSetup pageSetup = new PageSetup();
        pageSetup.setPageWidth(400f);
        pageSetup.setPageHeight(500f);
        pageSetup.setPageMargin(marging);
        pageSetup.setOrientation(PageSetup.OrientationEnum.LANDSCAPE);
        pageSetup.setLinenumber(linenumber);
        String folder = "input";
        String password = null;
        String destFilePath = "output/updatePageSetup_output.docx";
        sectionsApi.updatePageSetup(name, sectionIndex, pageSetup, destFilePath,folder, storage, password);
    }
}