Unable to render xlsx template in .net c#
-
I need some help when i try to render an xlsx template using the c# sdk it keeps returning the template instead of the rendered document
-
Please share some code...
-
So i created a helper method to handle the template and make the request
public async Task<byte[]> RenderExcelAsync(string exceltemplate, object exceldata, string excelhelperFunctions = null) { try { Template excelt = new Template() { Engine = Engine.Handlebars, Recipe = Recipe.Xlsx, Content = "{{{xlsxPrint}}}", Xlsx = new Xlsx() { TemplateAsset = new Asset() { Encoding = "base64", Content = exceltemplate } } }; if (!string.IsNullOrEmpty(excelhelperFunctions)) excelt.Helpers = excelhelperFunctions; RenderRequest req = new RenderRequest() { Template = excelt, Data = exceldata }; var result = await _service.RenderAsync(req); if (result.Content != null) { using (var memoryStream = new MemoryStream()) { result.Content.CopyTo(memoryStream); return memoryStream.ToArray(); } } else throw new ApplicationException("There was an error generating the PDF file."); } catch (Exception) { throw; } } }
it runs but instead of returning the rendered document it returns the template basically
-
Also tried running it using the jsreport studio and it worked but not from the hosted version of the jsreport i have could it be a version issue? version on the site is version: 2.11.0
-
Thanks... this looks good so far.
it keeps returning the template instead of the rendered document
Do you mean it returns xlsx file, but the original
exceltemplate
template without changed cells?
This would be expected, because you provide no calls hereContent = "{{{xlsxPrint}}}",