Reputation: 6668
I am sending an e-mail from excel using outlook. For the body of the e-mail I am making use of HTML.
I had a table which was working fine. However I have been asked to add a header above the current header of my table. The header is called "Premium / (Discount)". So the code below does that fine. However I would like for this header to span across two columns and centre.
I am using the line below but it is not working, why?
"<th colspan='2'>Premium /(Discount)</th>
msg = "<table style='font-size: 12pt;'><tr><th> </th><th> </th><th> </th><th> </th><th> </th><th> </th>" & _
"<th colspan='2'>Premium /(Discount)</th><th> </th><th> </th><th> </th><th> </th></tr>" & _
"<tr><th align='left'>Fund</th><th> </th>" & _
"<th align='left'>Market Spread %</th><th> </th>" & _
"<th align='left'>Tolerance</th><th> </th>" & _
"<th align='left'>Bid %</th><th> </th>" & _
"<th align='left'>Ask %</th><th> </th>" & _
"<th align='left'>Tolerance</th><th> </th>" & _
"<th align='left'>Extra Notes</th><th> </th></tr>"
Upvotes: 0
Views: 355
Reputation: 92
<html>
<body><table style='font-size: 12pt;'><tr>
<th></th><th></th><th></th><th colspan='2'>Premium /(Discount)</th><th></th><th></th></tr>
<tr><th align='left'>Fund</th>
<th align='left'>Market Spread %</th>
<th align='left'>Tolerance</th>
<th align='left'>Bid %</th>
<th align='left'>Ask %</th>
<th align='left'>Tolerance</th>
<th align='left'>Extra Notes</th></tr>
</table>
</body>
</html>
This will help "Premium / (Discount)" header to centre over the Bid % and Ask % column headers no matter the width of the columns.
NOTE: It won't center it the whole table.
Upvotes: 1
Reputation: 307
According to your code, your table has a total of 14 columns, so your colspan should be of 14
instead of 2
.
Also, you're using some of these columns as space : <th> </th>
. Note that you can do it better by adding a cell-padding value (in pixels) to your <table>
, so your table will look like this : http://cssdeck.com/labs/qyh7ytdi.
Here is the code that should do the trick:
msg = "<table style='font-size: 12pt;' cellpadding='5'>" & _
"<tr><th colspan='3'></th><th colspan='2'>Premium /(Discount)</th></tr>" & _
"<tr><th align='left'>Fund</th>" & _
"<th align='left'>Market Spread %</th>" & _
"<th align='left'>Tolerance</th>" & _
"<th align='left'>Bid %</th>" & _
"<th align='left'>Ask %</th>" & _
"<th align='left'>Tolerance</th>" & _
"<th align='left'>Extra Notes</th></tr>"
Upvotes: 2