I haven't looked too closely at your API, just at your output -- but i definitely think a majority of this should be done with CSS ... the value adds you can provide are:
- generating the xhtml tables from the raw data
- providing a rule based interface to add a CSS class to rows/columns/cells based on coderefs or regexes
- automaticaly sorting the data as specified
...i would leave the concrete specifics of how the rows/columns/cells look to a user supplied CSS. That way if i decide i want all the negative numbers to be in red instead of bold, i can just change my (possibly site global) CSS file, instead of editing the script that calls your module.
Your mechanism for prioritizing rules is interesting ... but i would avoid naming them red/ylw/grn ... it's too easy for people to assume those are color specific and not realize they relate to precedence. I would just have a precedence argument that is numeric, higher number wins (or lower, your choice) .. the interesting cases are:
- multiple rules have the same precedence? ... in that case i would just use all the CSS classes for that rule (it's legal to have multiple class names separated by space, the browser applies them all)
- should cell rules override row rules override column rules? .. i would say not necessarily, you can allow undef as a precedence and use that to indicate that it's applied no matter what other rules are picked based on their precedence (ie: it's equal to whatever the highest value found is). ... perhaps an optional method could be called by the client specifying an uber-precedence of row/col/cell (if this method is never used, their rules are all equal)