Search code examples
htmlhtml-tabletalend

Send output data as an HTML table


I am using Talend to create a report. The requirement is that the report is sent as an email in a tabular format with individual cells colour coded according to the values within. I successfully extracted and transformed the data however I am stuck with outputting the data as an HTML table part.

I could not find a component which outputs data as HTML. Is the only way to use a tJava and hardcode the table template inside whilst looping over the rows to update the values? Or is there a simpler way?

So after extracting the data I would have something like this:

header1,header2,header3
val1,val2,val3
val1,val2,val3
val1,val2,val3

And I need to output that in an HTML table format like so:

<table style="width:100%">
  <tr>
    <th>Header1</th>
    <th>Header2</th>
    <th>Header3</th>
  </tr>
  <tr>
    <td style="background-color: #ccc">Val1</td> //IF Val1 > x THEN color = y, etc
    <td>Val2</td>
    <td>Val3</td>
  </tr>
   <tr>
    <td style="background-color: #ccc">Val1</td> //IF Val1 > x THEN color = y, etc
    <td>Val2</td>
    <td>Val3</td>
  </tr>
   <tr>
    <td style="background-color: #ccc">Val1</td> //IF Val1 > x THEN color = y, etc
    <td>Val2</td>
    <td>Val3</td>
  </tr>
</table>

Solution

  • Talend Studio is a very powerful ETL (extract, transform, load) tool.

    It allows processed data to be put in file formats which can be used for further processing. This includes but is not limited to:

    • CSV
    • Excel
    • XML
    • JSON
    • any many others

    The calculation for the color field should happen inside this ETL job.

    On the other hand, if you want to create something which is not a processing file format in the first place, you have three options:

    1) Look if there is a custom component available which would you enable to do so - requires a component which is not abandoned and some configuration

    2) Use a tJavaRow and a tJava component to write your own code which would fill a file exactly in how you need it - requires good knowledge of Java and the structure of Talend

    3) Use a report system for this custom report you need. This could be anything which is capable of creating HTML files. For example TIBCO Jasper Reports, Python, maybe Tableau and other tools and programs. Requires a bit of knowledge in how to use the report system to build almost anything