I have MS Excel spreadsheets, where there are many cells with hyperlinks in them. I do not want the hyperlinks. Instead I want to use the visible texts in the cells only. How to get them?
Here is sample code
require 'roo-xls'
ifl = Roo::Spreadsheet.open(ifile)
sheet = ifl.sheet(0)
i = 0
while sheet.cell(i,0) != nil
key = sheet.cell(i,0) # these cells contain hyperlinks, not usual strings
puts key # url is printed here instead of the visible text of the link
i = i + 1
end
There is a different method to get the hyperlinks:
sheet.hyperlink(row, column)
sheet.cell(i,0).to_s
It's better to convert it into a string. roo does not have any method to removea hyperlinkfrom a cell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.