How to (programatically?) add text at the corner of every cell of a table?

I would like to place a number at a corner of each cell (i.e. top right) without disrupting the text in the cell. There’s fixed dimensions for every cell, and there’s hundreds of cells.

I suppose the obvious thing to do is to add a floating text frame, but I want it to be aligned exactly at the same place in every corner. Is there a way to do this programatically?