I have an SQL report (nasty example of “cross-tab”) which functions OK but the output from getAsHtml() is somewhat lacking - mostly with the numbers (integers) being suffixed with “.0” and left-justified.
I can deal with the “.0” suffix (simple string.replace()) but the left justification (which should be right justification for columns of numbers) has me stumped.
Does Servoy provide any way to influence the formatting in getAsHtml?
No it does not provide any formatting, we might add this in the future, but the code for creating a html table is very simple:
var out = '';
var numberOfColumns = set.getColumnCount();
out += '<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=0>'
out += '<TR>'
for(var x = 1; x <= numberOfColumns ; x++)
{
out += '<TD><B>'+getColumnName(x)+'</B></TD>'
}
out += '</TR>'
for(var j = 1 ; j <= set.getRowCount() ; j++)
{
out += '<TR>'
for(int x = 1; x <= numberOfColumns ; x++)
{
out += '<TD>'+set.getValue(j,x)+'</TD>'
}
out += '</TR>'
}
out += '</TABLE>'
Thanks for the tip. For the record, here’s the version I’m using:
var out = '';
var numberOfColumns = dataset1.getMaxColumnIndex();
out += '<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=0>'
out += '<TR ALIGN=CENTER>'
for(var x = 1; x <= numberOfColumns ; x++)
{
out += '<TH><B>'+dataset1.getColumnName(x)+'</B></TH>'
}
out += '</TR>'
for(var j = 1 ; j <= dataset1.getMaxRowIndex() ; j++)
{
out += '<TR ALIGN=RIGHT>'
// Handle first column (row labels) specially...
out += '<TD ALIGN=LEFT>'+dataset1.getValue(j,1)+'</TD>'
for(var x = 2; x <= numberOfColumns ; x++)
{
out += '<TD>'+dataset1.getValue(j,x)+'</TD>'
}
out += '</TR>'
}
out += '</TABLE>'
The tag somehow coerces the table headings to lower-case, but apart from that it’s fine (doesn’t even confuse the issue with “.0” suffixes on integers).