本文介绍了如何在axlsx中的单元格中添加超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用spreadsheet
宝石,您可以运行Spreadsheet::Link.new('http://hyperlinkhere.com', 'Some words')
来制作一个电子表格,该电子表格的单元格包含字符串"Some words",并带有指向" http://hyperlinkhere.com ."
With the spreadsheet
gem, you can run Spreadsheet::Link.new('http://hyperlinkhere.com', 'Some words')
to make a spreadsheet with a cell containing the string "Some words" with a hyperlink leading to "http://hyperlinkhere.com."
axlsx
等效项是什么?
如果我想写一个有多个单元格的行怎么办?
What if I want to write a row with more than one cell?
使用spreadsheet
,您可以执行以下操作:
With spreadsheet
, you can do this:
newSheetRow[13] = Spreadsheet::Link.new('url.com','text')
newSheetRow[14] = 'some text'
如何使用axlsx
的.add_row
方法来做到这一点?
How do I do that with axlsx
's .add_row
method?
推荐答案
您可以在工作簿和URL中添加链接.
You can add both links within workbook and URLs.
p = Axlsx::Package.new
book = p.workbook
book.add_worksheet(:name => 'hyperlinks') do |sheet|
# external references
sheet.add_row ['axlsx']
sheet.add_hyperlink :location => 'https://github.com/randym/axlsx', :ref => sheet.rows.first.cells.first
# internal references
sheet.add_hyperlink :location => "'Next Sheet'!A1", :ref => 'A2', :target => :sheet
sheet.add_row ['next sheet']
end
这篇关于如何在axlsx中的单元格中添加超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!