Replace sheet index with gid

The export CSV function seems to be broken as you need to pass the gid.