CreateFileFromDatas
Interface Function
According to the input argument "datas" and the document template to create a new word/excel/pdf file, and return the file id.
Request Parameter
Parameter | Required | Type | Remarks |
---|---|---|---|
templateCode | Yes | String | Document template code |
datas | Yes | Dictionary |
The data that should be filled into the document template |
transferPdf | No | bool | true:the generated file format is PDF; false:the generated file format is "Template File" file format; |
fileName | No | String | Generated file name, if it's null, it will be assigned by the value of the field "FileName" in Document Template. |
Return Data Type(Data)
Success: it's true if success, or false if fail.
Message: the value will not be empty if error occurs, it shows the error message.
Data (string): the created file id.
public class ResultMsg
{
public bool Success { get; set; }
public string Message { get; set; }
public string Data { get; set; }
}
Code example
var templateCode="ABC";
var datas = new []
{
Dictionary<string,object> { {"Field_A","A"},{"Field_B","B"},{"Field_C", DateTime.Now}}
};
var result = Service.CreateFileFromDatas(templateCode, datas, true);
Service.ConsoleLog("CreateFileFromDatas result", result);