From 20c7572361fa9b0ac79cc9f44ae0626aa8565cd8 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Fri, 16 Sep 2022 18:49:27 -0700 Subject: Clarify Hyperlinks Example for Internal Links --- examples/hyperlink_example.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'examples/hyperlink_example.md') diff --git a/examples/hyperlink_example.md b/examples/hyperlink_example.md index f6d21ca9..b732042a 100644 --- a/examples/hyperlink_example.md +++ b/examples/hyperlink_example.md @@ -10,17 +10,22 @@ require 'axlsx' p = Axlsx::Package.new wb = p.workbook -wb.add_worksheet(name: 'Hyperlinks') do |sheet| - # external references - sheet.add_row ['axlsx'] - sheet.add_hyperlink location: 'https://github.com/caxlsx/caxlsx', ref: 'A1' - # internal references - sheet.add_hyperlink location: "'Next Sheet'!A1", ref: 'A2', target: :sheet - sheet.add_row ['next sheet'] +wb.add_worksheet(name: 'Hyperlinks Examples') do |sheet| + # External References (HTML Links) + sheet.add_row ["External Link:", "Click here to see caxlsx on Github"] + sheet.add_hyperlink location: 'https://github.com/caxlsx/caxlsx', ref: "B1" + + # Internal References (Links pointing to within the Workbook) + sheet.add_row ["Internal Link:", "Click here to go to 'My Other Sheet Cell B1'"] + sheet.add_hyperlink( + location: "'My Other Sheet'!B1", ### This link will point to Cell B1 of the Worksheet named "My Other Sheet". + target: :sheet, ### This is :external by default. If you set it to anything else, the location is interpreted to be the current workbook. + ref: 'B2' ### Cell location of the link in this sheet + ) end -wb.add_worksheet(name: 'Next Sheet') do |sheet| - sheet.add_row ['hello!'] +wb.add_worksheet(name: 'My Other Sheet') do |sheet| + sheet.add_row ['Hello', 'World'] end p.serialize 'hyperlink_example.xlsx' -- cgit v1.2.3