i see, is your intention to use jsreport-core or jsreport directly? most users go with jsreport, core is for advanced uses cases but if you are just getting started just create new empty directory (no previous package.json in there or any other file, or any node_modules installed), and run jsreport init in there, that should install jsreport normally.
if your intention is to use jsreport-core and also the cli, you should also install the jsreport-cli in your project to make the commands work. if you just use jsreport package directly (not jsreport-core) then you should not worry about this, the cli will work there normally.
The jsreport.exe is compiled with normal node without extra localization. I am not sure how the size would grow if we would compile the localization there.
I believe we should get it running with full node and the arg NODE_ICU_DATA as you get it working in normal node.
The problem could be that we fork extra process for templating engine evaluation and this process doesn't get the NODE_ICU_DATA propagated.
Could you please try to change the config in v2 as this and try again with NODE_ICU_DATA set?
Thanks! will try to run it from cmd line then but I need it as a service running under a specific service account for the proxy authorization (worst setup ever), we are using NSSM to do that, not sure how could I run it as that specific user, this is a deep dive into nodejs for me. With regards, Michal
try to think about the execution context of the functions you have.
your add function, which is defined as template helpers is executed in server side context, it does not have access to the DOM, that is why everything you define in template helpers can be called as handlebars helpers.
remember that jsreport executes your template to get final html (generated by your template body, helpers calls and data), and then uses that html to evaluate it in a recipe which usually is a browser (phantom, chrome), so in that part everything you have as script tags inside your html is evaluated
You say there, "Another approach we recommend is to create the whole excel the first, upload it into jsreport and then only replace its data, which is simple."
However, there is no explanation of how to do this, or work with the uploaded file. I found in the Studio UI under 'xlsxTemplates' you can upload an Excel file from my local hard drive, but after that, I have no idea what to do. How do I access the file? What do I do to replace the data?
xlsx recipe works by modifying internal representation of xlsx (xml files using Office Open XML specification), we let your code to modify the files that are present inside the xlsx (the xlsx is a zip file that contains multiple xml files), you can use one of that helpers xlsxReplace, xlsxMerge, xlsxAdd that we provide to modify/add the contents to one of the internal files of the xlsx. the modifications that you should do are mostly about using the data that your template receives to create dynamic content that should be in the xml tags that are part of your final xlsx. each time that you use a xlsx helper you are modifying part of your final xlsx file.
i guess there is no deep guide of how to do this because we have not had the time yet to do it but we will as soon we finish some other stuff first.
I have no idea what to do.
if you are going to upload an xlsx file that contains some pre-defined layout, then in order to know how to modify by code in jsreport template you should know first how it looks, on your computer you can rename your .xlsx file to .zip then unzip it and inspect all the internal files there, there are a lot there but you should try to focus mostly in for example xl/worksheets/sheet1.xml that contains the content of the cells, then you can use one of the helpers that we provide to add/modify/replace xml tags inside it.
What do I do to replace the data?
just use the helpers that we provide, specify the target paths to modify and put xml tags that should be the new content or should be added, depending on the specific helper that you use.
i know all of this sounds hard, but this is the most powerful way that we found to create dynamic xlsx with rich content. we hope that we can make this more easy in the future, let's see. for the time being i have added a note to out internal tasks to add some guide on how to work with existing xlsx files that contain layout
i see, remember that you can email me the project in case your are still curious to know the exact reason of the failure, it can also be another prove that something weird is happening in your machine.