I have a Ruby code that iterates over some objects creating the necessary rows in an xls file using Axlsx gem.
Some of the object attributes are links (social handles and website), and I want these to be displayed as clickable links in the xls file. There can be multiple different links in the same cell, and I want each one to be a hyperlink.
So the question is, is there a way to tell the workbook to auto detect cells that contain texts that are links and display them as hyperlinks (like Word does when you type)?
Or if there is not, How can I make a certain cell be displayed as hyperlink?
This is the code I use to create the rows:
package = Axlsx::Package.new
package.use_shared_strings = true
package.use_autowidth = true
workbook = package.workbook
workbook.add_worksheet(name: sheet_name) do |sheet|
add_headings_row(sheet)
businesses.each do |business|
[:id, name, :website, :social_handles, :phone].each do |method_name|
columns << business.send(method_name)
end
sheet.add_row(columns, style: rows_style)
end
end
What I'm asking is not how to make a single cell a hyperlink, that has been answered here, but how to automatically detect the text in a cell to be clickable (not the whole cell because there can be multiple links in the same cell), or at least how to manually make each line be clickable.