Home » excel » How to Write hyperlinks using spreadsheet gem in Ruby?

How to Write hyperlinks using spreadsheet gem in Ruby?

Posted by: admin March 9, 2020 Leave a comment

Questions:

The spreadsheet gem isnt documented properly, so I cant understand how can I write hyperlinks using spreadsheet gem. Can anyone tell me?

How to&Answers:

This script will create a spreadsheet with a link in the first cell

require 'rubygems'
require 'spreadsheet'

book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet
sheet1[0,0] = Spreadsheet::Link.new 'www.google.com', 'link text'
book.write '/tmp/spreadsheet_with_link.xls'

Answer:

According to the Guide you have to write to a new file name: https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md