How to I add a hyperlink to a cell in axlsx?

后端 未结 1 1130
有刺的猬
有刺的猬 2020-12-10 19:41

With the spreadsheet gem, you can run Spreadsheet::Link.new(\'http://hyperlinkhere.com\', \'Some words\') to make a spreadsheet with a cell contain

相关标签:
1条回答
  • 2020-12-10 20:16

    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
    
    0 讨论(0)
提交回复
热议问题