JsonDataSource
内容
[
隐藏
]JsonDataSource(string)
使用解析 JSON 数据的默认选项,使用来自 JSON 文件的数据创建新的数据源。
public JsonDataSource(string jsonPath)
| 范围 | 类型 | 描述 |
|---|---|---|
| jsonPath | String | 用作数据源的 JSON 文件的路径。 |
也可以看看
- class JsonDataSource
- 命名空间 Aspose.Words.Reporting
- 部件 Aspose.Words
JsonDataSource(Stream)
使用解析 JSON 数据的默认选项,创建一个包含 JSON 流数据的新数据源。
public JsonDataSource(Stream jsonStream)
| 范围 | 类型 | 描述 |
|---|---|---|
| jsonStream | Stream | 用作数据源的 JSON 数据流。 |
也可以看看
- class JsonDataSource
- 命名空间 Aspose.Words.Reporting
- 部件 Aspose.Words
JsonDataSource(string, JsonDataLoadOptions)
使用指定的选项解析 JSON 数据,创建一个包含 JSON 文件中数据的新数据源。
public JsonDataSource(string jsonPath, JsonDataLoadOptions options)
| 范围 | 类型 | 描述 |
|---|---|---|
| jsonPath | String | 用作数据源的 JSON 文件的路径。 |
| options | JsonDataLoadOptions | 解析 JSON 数据的选项。 |
例子
展示如何使用 JSON 作为数据源(字符串)。
Document doc = new Document(MyDir + "Reporting engine template - JSON data destination.docx");
JsonDataLoadOptions options = new JsonDataLoadOptions
{
ExactDateTimeParseFormats = new List<string> {"MM/dd/yyyy", "MM.d.yy", "MM d yy"},
AlwaysGenerateRootObject = true,
PreserveSpaces = true,
SimpleValueParseMode = JsonSimpleValueParseMode.Loose
};
JsonDataSource dataSource = new JsonDataSource(MyDir + "List of people.json", options);
BuildReport(doc, dataSource, "persons");
doc.Save(ArtifactsDir + "ReportingEngine.JsonDataString.docx");
也可以看看
- class JsonDataLoadOptions
- class JsonDataSource
- 命名空间 Aspose.Words.Reporting
- 部件 Aspose.Words
JsonDataSource(Stream, JsonDataLoadOptions)
使用指定的选项解析 JSON 数据,创建一个包含 JSON 流数据的新数据源。
public JsonDataSource(Stream jsonStream, JsonDataLoadOptions options)
| 范围 | 类型 | 描述 |
|---|---|---|
| jsonStream | Stream | 用作数据源的 JSON 数据流。 |
| options | JsonDataLoadOptions | 解析 JSON 数据的选项。 |
例子
展示如何使用 JSON 作为数据源(流)。
Document doc = new Document(MyDir + "Reporting engine template - JSON data destination.docx");
JsonDataLoadOptions options = new JsonDataLoadOptions
{
ExactDateTimeParseFormats = new List<string> {"MM/dd/yyyy", "MM.d.yy", "MM d yy"}
};
using (FileStream stream = File.OpenRead(MyDir + "List of people.json"))
{
JsonDataSource dataSource = new JsonDataSource(stream, options);
BuildReport(doc, dataSource, "persons");
}
doc.Save(ArtifactsDir + "ReportingEngine.JsonDataStream.docx");
也可以看看
- class JsonDataLoadOptions
- class JsonDataSource
- 命名空间 Aspose.Words.Reporting
- 部件 Aspose.Words