I met Andrew last night and he had been playing around with Extension Objects using my previous 3 steps as a starter. He pointed out one glaring omission - how do you add headers! Doh! I had done it before but just failed to add it to the table example.
Headers are actually pretty easy (like a lot of this stuff). We have already seen the this.Data.rows property. Well the Data class also exposes a HeaderRows property. This has a length value but I can't really see where there would be more than one row. Anyway, we just need to extract the text values from the property just as we have done before:
// Add the Header row
var headerRow = this.Data.HeaderRows;
html += "<tr><th>" + headerRow.text + "</th><th>" + headerRow.text + "</th></tr>";