打开一个新的模板文件
新建的时候默认打开已存在的模板文件,在改模板文件中进行修改可以直接打开,但是默认打开的是\templates 下面的文件,也就是默认打开的是模板,然后需要自己进行另存为
使用方法如下:
var viewer = null;
GrapeCity.ActiveReports.Designer.create('#designer-id1', {
//自己控制属性
}).then(api => {
api.documents.create({ template: {id: "传入报表名称即可(比如:OrganizationBrandedReport.rdlx)"}})
})比如上面默认打开的模板就是如下:
如果想要打开resource目录下的原文件也可以,需要修改一个方法:
原本他是默认打开的是template下的文件,我们将他改成自己修改的路径即可,比如想打开resource目录下的
可以参考如下方法:
const string templateThumbnailName = "template_thumbnail";
public ActionResult GetTemplate( ITemplatesService templatesService, string id)
{
if (string.IsNullOrWhiteSpace(id)) return BadRequest();
String filePath = @"D:\AR\example\git-exam\WebSamples16-1\WebSamples16\WebDesignerSamples\WebDesigner_MVC_Core\resources";
var fullPath = Path.Combine(filePath, id);
if (!System.IO.File.Exists(fullPath)) throw new FileNotFoundException();
var templateXml = System.IO.File.ReadAllBytes(fullPath);
var template = ReportConverter.FromXML(templateXml);
var thumbnail = template.EmbeddedImages.FirstOrDefault(i => i.Name == templateThumbnailName);
if (thumbnail != null) template.EmbeddedImages.Remove(thumbnail);
var templateJson = ReportConverter.ToJson(template);
return File(templateJson, "application/json");
}里面filePath可以自行修改
页:
[1]