Clever hack using data-attributes to assign labels to cells.
data-
It's still a massive duplication of code (labels), but better and more lightweight than most solutions I've seen for this surprisingly tricky problem.