【问题标题】:Ruby Roo gem: how to extract the hyperlink text from a cell that contains hyperlink?Ruby Roo gem:如何从包含超链接的单元格中提取超链接文本?
【发布时间】:2020-08-11 15:16:41
【问题描述】:

我有 MS Excel 电子表格,其中有许多带有超链接的单元格。我不想要超链接。相反,我只想使用单元格中的可见文本。如何获得?

这里是示例代码

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

【问题讨论】:

  • 向我们展示您迄今为止尝试过的代码。
  • 在原帖中添加代码

标签: excel ruby hyperlink roo


【解决方案1】:

获取超链接有不同的方法:

sheet.hyperlink(row, column)

【讨论】:

    猜你喜欢
    • 2011-08-04
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 2013-12-10
    相关资源
    最近更新 更多