25.8 HTML and Markdown Report

From Origin 2019b, Notes window supports two modes: ordinary Edit Mode and Render Mode. When you edit a report according to HTML or Markdown syntax in Note Widows, you can show the report by render Mode. In the report, you can refer to Origin graph, image in matrix, analysis table and any worksheet cells. When the source changes, the linked in Notes window also get updated. This render mode makes it possible for Notes window to serve as an analysis report.

Switch to Render mode

The default mode of Notes window is text mode. To switch to Render mode, you can use one of these four methods:

  • Select HTML: Render Mode in the menu
  • Right-click on the Note window title, and select Render Mode
  • Active Note Window, and press Ctrl + M hotkeys
  • Run Labtalk script:
note.view=1;
Notes: If you use Markdown syntax in the Notes Window, you must change Syntax to Markdown before changing to Render Mode.


Syntax in the Notes Winow

In Note widow, the edit mode default shows plain text as syntax option. When you edit by HTML or Markdown syntax, you can change the Syntax option. The HTML will shows the colored of the HTML syntax , while the Markdown syntax could help the Render Mode identify it is using Markdown syntax.

To switch to Syntax option, you can use these methods:

  • Select HTML: Syntax: Text / HTML / Markdown in the menu
  • Right-click on the Note window title, and select Syntax: Text / HTML / Markdown
  • Run Labtalk script:
note.syntax=0; //switch to plain text
note.syntax=1; //switch to colored HTML syntax
note.syntax=2; //switch to Markdown

Show line number

When Notes Windows in edit mode, you can check HTML: Display line numbers to show the line numbers.


Insert links of Origin Object, String and Variable

Graphs, singel cell, tables, matrix, string and variable are supported to insert into Note window with HTML or Markdown syntax.

When using HTML or Markdown syntax to edit in Notes window, you can use this syntax to insert the links into the Notes window:

{{type://notation}}


Following link types are suppported.

type notation Description Samples
graph the graph window name Insert a graph window as an image (.png). <img alt="{{graph://Graph1}}">
matrix the matrix window name Insert a matrix image. <img alt="{{matrix://matrix1}}">
cell range of the cell Insert a worksheet cell content as a string.
The syntax is [book_name]sheet_name!column_name[row-index].
{{cell://[book1]1!B[3]}}
table range of the table Insert a table (from report sheet) as a HTML table.
The syntax is [book_name]sheet_name!table_name.
{{table://[Book2]FitLinear1!Parameters}}
str the Labtalk script of string Insert string, for example Labtalk String Registers

{{str://mystring$}}
{{str://%G}} (display current project name)
{{str://%@F}} (display current Project Explorer folder name)

var the Labtalk script of variable Insert variable

{{var://system.path.program$}} (display the program folder path)
{{var://[Book1]!page.info.SYSTEM.IMPORT.FILENAME$}} (display imported file name)


  1. You can use Copy and Paste Link to insert Origin objects. When Note window is in text mode, you can Copy the Origin object and then in the Note window to insert syntax code by Paste Link.
  2. When the Notes window is switched to Render mode, if a graph is inserted in the Note, an image file (.png) of the graph is generated and replace the image tag with the png path. When graph is updated, the Notes window is updated accordingly.


Use Placeholders to insert links

In the Notes window, it support use placeholders to insert link. These is a special Workbook named HTML to list the placeholders and the links.

To open the Workbook listed the placeholders:

  • Select HTML: Edit Placeholders... in the menu
  • Right-click on the Note window title, and select Edit Placeholders...


In the Workbook, the first column are the name of the Placeholders, and cells in the second column lists the content of the links. You can insert variable and graph in the cell, and use this syntax to insert placeholders into the Notes window:

{{Placeholder}}


To add the links in the placeholder worksheet:

  • Use Copy and Paste Link to add links of the Origin Object, String and Variable in the cells of the second column of this worksheet.

or

  • Right-click on the cells of the second column, select Insert Graph... or Insert Variables... to insert links.

Report Example

You can refer some of our build samples by selecting HTML: Load Samples:... in the menu.

Here, we create a Linear Fit result report by HTML, HTML with Placeholders and Markdown respectively. You can compare their difference.

First, we need to prepare the analysis. Create a new project and import data <Origin installation folder>\Samples\Curve Fitting\Sensor01.dat into Book1. Highlight worksheet and create a scatter plot. Do a linear fit (Analysis: Fitting: Linear Fit) with default settings.

Example 1: Create a HTML Report

  1. Create a new Note window and enter the following syntax
    <html>
    <head>
    <style>
    	td {
    		text-align: center;
    	}
    </style>
    </head>
    
    <body>
    	<h1 style="color:#4285F4">Linear Fit Report</h1>
    	<b>File Information:</b></br>
        <table class="origin-table centered" width="400px" >
        <tr>
            <th>File Name</th> 
            <th>Fitting Equation</th>    
        </tr>
         <tr>
            <td>Sensor01</td> 
            <td>{{cell://[Sensor01]FitLinear1!Notes.Equation}}</td>
        </tr>
        </table>
    	</br>	
    	<b>Fitted Parameters & Statistics:</b></br>
        <table class="origin-table centered" width="700px" >
        <tr>
             <th>Intercept</th>
             <th>Slope</th>
             <th>Degrees of Freedom</th>
             <th>R-Square (COD)</th>
             <th>Adj. R-Square</th>
        </tr>
        <tr>
             <td>{{cell://[Sensor01]FitLinear1!Parameters.Intercept.Value}}&#177; {{cell://[Sensor01]FitLinear1!Parameters.Intercept.Error}}</td>
             <td>{{cell://[Sensor01]FitLinear1!Parameters.Slope.Value}} &#177; {{cell://[Sensor01]FitLinear1!Parameters.Slope.Error}}</td>
             <td>{{cell://[Sensor01]FitLinear1!RegStats.C1.DOF}}</td>
             <td>{{cell://[Sensor01]FitLinear1!RegStats.C1.RSqCOD}} </td>
             <td>{{cell://[Sensor01]FitLinear1!RegStats.C1.AdjRSq}}</td>
        </tr>   
        </table>
    	</br>
    	<img alt="{{graph://Graph1}}" width=350>
    </body>
    </html>
  2. Right-click on the window title, and select Render Mode. You can see the report like this:
    HTML Report 01.png

Example 2: Use Placeholders insert links in HTML Report

  1. Create a new Note window, and enter the following syntax
    <html>
    <head>
    <style>
    	td {
    		text-align: center;
    	}
    </style>
    </head>
    
    <body>
    	<h1 style="color:#4285F4">Linear Fit Report</h1>
    	<b>File Information:</b></br>
        <table class="origin-table centered" width="400px" >
        <tr>
            <th>File Name</th>  
            <th>Fitting Equation</th>    
        </tr>
         <tr>
            <td>Sensor01</td>  
            <td>{{Fitting.Equation}}</td>
        </tr>
        </table>
    	</br>	
    	<b>Fitted Parameters & Statistics:</b></br>
        <table class="origin-table centered" width="700px" >
        <tr>
             <th>Intercept</th>
             <th>Slope</th>
             <th>Degrees of Freedom</th>
             <th>R-Square (COD)</th>
             <th>Adj. R-Square</th>
        </tr>
        <tr>
             <td>{{Intercept}}&#177; {{Intercept.Error}}</td>
             <td>{{Slope}} &#177; {{Slope.Error}}</td>
             <td>{{DOF}} </td>
             <td>{{R-Square}} </td>
             <td>{{Adj.R-Square}}</td>
        </tr>   
        </table>
    	</br>
    	<img alt="{{FittedCurve}}" width=350>
    </body>
    </html>
  2. Right-click on the Note window title, and select Edit Placeholders... to open the worksheet. Enter placeholders name in the first column. Copy and paste the links of the fitting result in the second column.
    Placeholders Worksheet.png
  3. Right-click on the window title, and select Render Mode. You can get the report the same as Example 1.

Compare the HTML syntax in Example1, you will find the placeholders help to simplify the HTML in Example2.

Example 3: Create a Markdown Report

  1. Create a new Note window and enter the following syntax.
    # Linear Fit Report
    
    **File Information:**
    |File Name|Fitting Equation|
    |--|--|
    |{{File.Name}}|{{Fitting.Equation}}|
    
    
    **Fitted Parameters & Statistics:**
    |Intercept|Slope|Degrees of Freedom|R-Square (COD)|Adj. R-Square|
    |--|--|--|--|--|
    |{{Intercept}}&#177;{{Intercept.Error}}|{{Slope}} &#177; {{Slope.Error}}|{{DOF}} |{{R-Square}}|{{Adj.R-Square}}
    
    <img alt="{{FittedCurve}}" width=350>
  2. Right-click on the Note window title, and select Edit Placeholders... to open the worksheet. Enter placeholders name in the first column. Copy and paste the links of the fitting result in the second column, like step2 of Example 2.
  3. Right-click on the Note window title, and select Syntax: Markdown.
  4. Right-click on the window title again, and select Render Mode.

Compare the HTML syntax in Example1, you will find Markdown syntax is easy to edit, but it can not support the some special styles in HTML.