This re-implements a bunch of stuff from View / format.data.frame. Using the latter would be a good plan at least.