Skip to content

Commit b87e0f8

Browse files
committed
If the contents of a cell is a URL and does not include a formula, use the HYPERLINK formula to make it clickable.
This also gets around the 65,530 hyperlinks per Worksheet limit in Excel as these `HYPERLINK` formulas do not contribute to that count. Related to #475.
1 parent 73ed8c2 commit b87e0f8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lib/rubyXL/worksheet.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrit
5757
end
5858
c.raw_value = data
5959
c.datatype = RubyXL::DataType::RAW_STRING
60+
if data.match?( URI::DEFAULT_PARSER.make_regexp ) # If content is a URL then use the HYPERLINK formula to make it clickable.
61+
c.formula = RubyXL::Formula.new(:expression => %(HYPERLINK("#{ data }")))
62+
end
6063
when RubyXL::RichText then
6164
if data.to_s.length > TEXT_LENGTH_LIMIT_IN_CELL
6265
raise ArgumentError, "The maximum length of cell contents (text) is #{TEXT_LENGTH_LIMIT_IN_CELL} characters"

0 commit comments

Comments
 (0)