I'm trying to generate a sheet which has a column of URLs which I would like to present as hyperlinks, not just text. All the examples I've found, show adding a hyperlink this way:
sheet.add_hyperlink :location => 'https://github.com/randym/axlsx', :ref => sheet.rows.first.cells.first
This works if you're just trying to put one hyperlink somewhere on the page, but I'm iterating over a collection and each row will have a link in a certain column, depending on which columns are present.
I attempted the following:
@items.each do |item|
row = []
idx = 0
...
idx += 1
row << item.address
url_idx = idx
...
r = sheet.add_row row
sheet.add_hyperlink :location => item.address, :ref => r[url_idx]
end
but that just resulted in an error:
undefined method `[]' for #<Axlsx::Row:0x007fa0024fb600>
This really seems more complicated than it should be so I think I'm missing something obvious.