How to generate a text file in asp.net core (Razor) by using a static text template - asp.net-core-3.1

I want to generate a file in ASP.Net Core using a pre-defined template. The template has several variables which has to be replaced by the values in the generated file. Template has "%" wildcard to identify the variable. For example, In the attached image, %SITECODE% should be replaced by the actual value.

Related

Excel template translator JETT to append data to workbook based on template

I am using JETT to generate xls from xls template. My input data will be given in pages is there way to append data to sheet as well applying template from input xls to output workbook using Jett api's
It is definitely possible.
You can write some script code at the beginning of your sheet (with ${{ /*your code here;*/ return '';}} . This code will get the data from the sheets using POI API and will store it in some variables. See how to access POI API from JETT Script here: http://jett.sourceforge.net/expressions/poi_objects.html ).
Once the data is stored into variables, you can insert them in sheets with standard JETT templating capabilities, by referring to the variables that you created in your script block.
Just make sure that the code block creating the variables with data lies before the place where the variables are used in your template.

How to add CoverPage and TOC while generating document programmatically

Hi I am trying to generate report programmatically from EA using C#.
Project.RunReport
By referring this.
But the problem is RunReport allows to choose only main template by passing the parameters
PackageGUID: String - the GUID of the Package
or master document to run the report on
TemplateName: String - the
document report template to use; if the PackageGUID has a stereotype
of MasterDocument, the template is not required
FileName: String - the
file name and path to store the generated report; the file extension
specified will determine the format of the generated document - for
example, RTF, PDF
How to set coverPage and TOC using this RunReport API call..?
Your report should already have a Cover page and TOC defined with it Seems like you will need to use DocumentGenerator or add the TOC Manually after the document is generated as you cannot insert a TOC in a Report Template.
If you want to define those separately, use the DocumentGenerator facility
Document Generator Reference

Matching of data files to pages

I have used the assemble/boilerplate-site as a test bed. Following the examples on http://assemble.io/docs/Data.html I have created a page named test.hbs and a data file named test.yml.
The yaml file contains:
title: stuff
when running grunt assemble, a test.html page is assembled into the destination directory. if my test.hbs contains the tag {{title}} the title is not added from the data file, however a tag of {{test.title}} does add the title from the data file.
on the docs page http://assemble.io/docs/options-data.html it states:
When using "external" data files (versus YAML front matter), if name of the data file is the same as the associated template then Assemble will automatically associate the two files.
I also need to use the {{title}} tag in my layout. This works if I use YFM at the top of the page rather than an external data file.
Am I misunderstanding how external data files are associated with a page or am I missing something?
You can use {{page.title}} in your test.hbs and layout.hbs files to access the variable without having to specify the actual page name.

Possibility of more then one xml input to jet?

Can we give more then one xml input to jet(java emitter template)?
If we can, then please give me an example.
You can't do it directly, but there are several techniques you can use to specify multiple XML's as input.
You can name one XML file inside the other or create a third XML file that simply names the two inputs (or however many you have). Say you have an XML file named in the input XML to JET:
<inputs>
<input name="...full file name here..." />
<inputs>
You can load this file in for use in JET like this:
<c:load url="{/inputs/input/#name}" var="root"/>
The load tag reads a file (defaults to XML, but other types can be input.) and makes its contents available via the variable name you specify ("root" in this case). Normally the url attribute expects a String value that is the file name, but since we're using an attribute out of the model we use the curly brackets and xpath notation to indicate the attribute value to use as the file name.
Once you've loaded the file in you can access its contents. For example, if the root element in that XML file was and it had an attribute named company, then you attribute could access that attribute value with the c:get
<c:get select="$root/policies/#company" />
You can load as many files as you want. Just use a different variable name to refer to the root of each parsed file.
You could get a bit more complex and store your multiple files in the same directory using a naming convention. Then you could just specify the one directory path and derive the file names for all of your inputs.

Purpose for Word Open XML and content controls binding

For word report generation, I am looking at binding XML to content controls to see if it is any easier than to use Word Interop and hardcode index reference to content controls to assign values to them.
However, I don't really understand how to do it.
My work flow is entering information in Excel and then generate an XML file to have content controls populated by XML, however, what I read is the other way round: Word Control Control Toolkit and descriptions where the XML is populated by user entering information in Word, and then programmer to unzip docx file to retrieve the XML file.
How can I populate content controls with XML?
There are samples on generating Word documents from Word templates, XML and data bound content controls # http://worddocgenerator.codeplex.com/
Set up the mapped content controls in the 'template' docx using the content control toolkit or similar. Do this using a sample XML file containing your Excel data.
Now you have that template document, at run time you can inject your XML file into it (ie replace the custom xml part it contains, with your instance data), in C# or Java or whatever.
When the user opens the document in Word 2007/2010, the information in the custom XML part will automatically be copied into the bound controls, and visible to the user.
Note that content control data binding doesn't easily support repeating data (eg populating table rows) in Word 2007/2010, though there are ways to do it.