对 Word 文档进行邮件合并。
接口方法 1:mailMerge() 合并数据到合并域
HTTP 请求方法:PUT
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/mailMerge
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
password | 否 | string | 原文档密码,没有则为null | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
data | 是 | array[object] | 用于合并的数据源 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
using System.Collections.Generic;
namespace MailMerge
{
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 MailMergeApi mailMergeApi = new MailMergeApi(wordConfiguration);
static void Main(string[] args)
{
string name = "mailMerge.doc";
List data = new List();
data.Add(new MailMergeData("Contact Name", "E-iceblue"));
data.Add(new MailMergeData("Fax", "TestFax"));
data.Add(new MailMergeData("Date", "2020-5-10"));
string folder = "input";
string storage = null;
string password = null;
string destFileName = "output/mailMerge_output.docx";
mailMergeApi.MailMerge(name, destFileName, data, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.MailMergeApi;
import spire.cloud.word.sdk.client.model.MailMergeData;
import java.util.*;
public class MailMeger {
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 MailMergeApi mailMergeApi = new MailMergeApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "mailMerge.doc";
List<MailMergeData> data = new ArrayList<MailMergeData>();
data.add(new MailMergeData("Contact Name", "E-iceblue"));
data.add(new MailMergeData("Fax", "TestFax"));
data.add(new MailMergeData("Date", "2020-5-10"));
String folder = "input";
String storage = null;
String password = null;
String destFileName = "output/mailMerge_output.docx";
mailMergeApi.mailMerge(name, destFileName, data, folder, storage, password);
}
}