Just make table normally after that just convert rows to column using this function
function rowINTOcolumn(tableid){
$jq("#"+tableid).each(function() {
var $jqthis = $jq(this);
var newrows = [];
$jqthis.find("tr").each(function(){
var i = 0;
$jq(this).find("td").each(function(){
i++;
if(newrows[i] === undefined) { newrows[i] = $jq("<table><tbody><tr></tr></tbody></table>"); }
newrows[i].append($jq(this));
});
});
$jqthis.find("tr").remove();
$jq.each(newrows, function(){
$jqthis.append(this);
});
});
}
pass ID of table