0

I've a table from a CSV which is converted by HTML and sent by email using Talend. To build the CSV to a HTML I am using a JavaRow:

componentcontext.MsgCode = "<br><br><style>table, td {  word-wrap: keep-all; border: 1px solid black;    border-collapse: collapse;}table, th { border: 1px solid black;}th, td {padding: 5px;},th {text-align: right;},th {background-color: #f2f2f2;},td{font-family: arial; font-size: 10pt;}</style> <table style=width:150px><tr> <th>column_A</th> <th>column_B</th> <th>column_C</th> <th>column_D</th>";

context.TableRow = "</td><td>"+input_row.column_A +"</td> <td>"+input_row.column_B +"</td> <td>"+input_row.column_C +"</td> <td>"+input_row.column_D+"</td> </tr>" + context.TableRow;

context.MsgCode = context.MsgCode + context.TableRow+ "</table>";

With this code I am getting the colours and the structure that I want however the size of the columns is comming very bad. For example, I am getting the following output:

enter image description here

What I have to add on my code in order to get the table with the correct columns sizes? I already change the style=width to 100% but without any good result. I want to have the following output:

enter image description here

Anyone can help me?

jww
  • 97,681
  • 90
  • 411
  • 885
Pedro Alves
  • 1,004
  • 1
  • 21
  • 47

1 Answers1

0

In a job of mine we solved it like this: (Works really well with Outlook, not sure about other tools though).

The whole content is wrapped in a table like this:

<tr>
    <td width="660">
        <div style="width:100%; margin:0 auto; text-align: center;">
            <font color="#1E4191" style="font-size:30px;">
                <strong>Data Load Report</strong>
            </font>
        </div>
        <br><br>
 <table><tr bgcolor="#F3E2A9"><td bgcolor="#F3E2A9"><font color="#1E4191" >Hello</font></td>

and so on

</font></td></tr></table>
            <br>
            <font color="#1E4191" face="Arial">
            Kind Regards, <br>
            <strong>Talend Team</strong>
             </font>
        </td>
    </tr>
</table>

Yes for each and every cell we need to define the font type and color :(

This works really well in outlook, and if the table doesn't fit the predefined 660px width then it gets broken to multiple lines.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Balazs Gunics
  • 2,017
  • 2
  • 17
  • 24