Generate Doc Report From Controller Action
-
Can someone provide me the code for generating Doc Report From Controller's Action?
-
public class HomeController : Controller { public IJsReportMVCService JsReportMVCService { get; } public HomeController(IJsReportMVCService jsReportMVCService) { JsReportMVCService = jsReportMVCService; } public async Task<IActionResult> Test() { var docxTemplate = Convert.ToBase64String(System.IO.File.ReadAllBytes("c:\\temp\\message.docx")); var result = await JsReportMVCService.RenderAsync(new RenderRequest { Template = new Template { Recipe = Recipe.Docx, Engine = Engine.Handlebars, Docx = new Docx { TemplateAsset = new Asset { Encoding = "base64", Content = docxTemplate } } }, Data = new { message = "Hello world" } }); return new FileStreamResult(result.Content, "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { FileDownloadName = "test.docx" }; } }