Export To HTML
ExportToHtml() function is used to generate HTML files from HTML template.
To perform this function, we need to type formula in formula bar i.e. =ExportToHtml.SK() as shown in Fig.
An HTML template needs to be created in order to use Export To HTML. We insert special SheetKraft tags so that data can be inserted dynamically and also repeated to show as many rows as required. To create this template you can create a standalone HTML template as shown in the second image or you can use the Markdown to HTML and Table to HTML feature to create the template in the worksheet.
Understanding SheetKraft tags in the template: There are 2 types of tags used in SheetKraft - sk:Replace and sk:Repeat - to put your data in HTML formats.
sk:Replace: This is the most basic tag which assigns data fields where data will be pasted. It can be used as a Static tag or inside a Repeat tag as is required.
sk:Repeat: This is a container tag when there is repeating data to be filled in. It is supposed to have one or more repeat tags and the entire container will be repeated until all the data rows are covered.
Follow below steps after you create the template.
ExportToHtml() function accepts the following arguments:
Template: Required. Provide the path of HTML template. (Use Relative path of HTML template)
ToFile: Required. This field accepts a Boolean value (TRUE/FALSE). Wehn set to TRUE, you will get HTML in a file, when FALSE, entire HTML will be pasted in a cell.
File: Optional. If Tofile field has TRUE value, provide the path for the output file that will be generated. If no path is provided, then output file will be generated on the Temporary (TEMP) path within SheetKraft Folder.
StaticTags: Required. Array or range of static tag names. Static tags are the fields that are fixed and have one-to-one mapping with the values that are provided in Excel. These tags should match exactly with the tag names provided in the HTML template file. Static tags correspond to the sk:Repeat tag names created outside sk:Repeat containers.
HTML Template with SheetKraft tags
StaticValues: Array or range of values corresponding to the static tag names.
RepeatTags: Array or range of repeating tag names. (Provide the tag names whose fields are to be repeated.)
RepeatRange1: Range corresponding to the first repeat tag. (Provide the column data for the fields that will be repeated.)
ReportTags1: Array or range of tags in the first repeat range. (Provide the tags to be exported to the html file as a header to the list or table.). For example: column_1 and column_2 is the report tags (ReportTags1) within the first repeat tag as shown in the following code block: Here the column fields are to be repeated within table having repeat tag as table tag.
Report1: Provide the order/sequence of data that will be exported to html. The data is provided within the Report.SK() function.
After Report1 field, data for second repeat tags are provided, that is, RepeatRange, ReportTags, and Report.SK () respectively. Providing all the details of arguments in the ExportToHtml() function, will generate the HTML file.
Sample HTML Format:
Before selecting the option for Exporttohtml, the data in the HTML template should be made familiar with the required/relevant Tags in Function arguments.
Provide Function Arguments As per HTML Template.
Mention StaticTags, StaticValues, RepeatTags Present in HTML Template along with all other arguments as shown in fig.
Click on the Run Book button to run Workbook. Output file will Generated at the folder where ,we provide path to export HTML file or output file will be generated on the Temporary (TEMP) path within SheetKraft Folder.