Ordnance Survey grids - download or generate?
The 'National Grid Shape file' can be downloaded at: https://github.com/charlesroper/OSGB_Grids
Using this for a OS grid at a specific resolution would take some aggregation based on the TILE field, or by using the SCALE field.
One alternative may be to populate the attributes yourself?
Provided that your generated grids are polygons rather than lines, you could use Easting and Northing figures to populate a field for each object.
There will obviously be some conversion of the numeric grid references to the OS Grid Ref, however there are plenty of example scripts out there to work from:
- Javascript: http://www.movable-type.co.uk/scripts/latlong-gridref.html
- PHP: http://www.jstott.me.uk/phpcoord/
- Python: http://oliverobrien.co.uk/2010/02/en-to-gridref-in-python/