Class: Writexlsx::Worksheet::HyperlinkCellData

Inherits:
CellData
  • Object
show all
Defined in:
lib/write_xlsx/worksheet.rb

Overview

:nodoc:

Constant Summary

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary

Attributes inherited from CellData

#col, #link_type, #range, #result, #row, #tip, #token, #url, #xf

Instance Method Summary collapse

Methods inherited from CellData

#cell_attributes

Methods included from Utility

#absolute_char, delete_files, #put_deprecate_message, #substitute_cellref, #underline_attributes, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Constructor Details

#initialize(worksheet, row, col, index, xf, link_type, url, str, tip) ⇒ HyperlinkCellData

Returns a new instance of HyperlinkCellData.



206
207
208
209
210
# File 'lib/write_xlsx/worksheet.rb', line 206

def initialize(worksheet, row, col, index, xf, link_type, url, str, tip)
  @worksheet = worksheet
  @row, @col, @token, @xf, @link_type, @url, @str, @tip =
    row, col, index, xf, link_type, url, str, tip
end

Instance Method Details

#dataObject



212
213
214
# File 'lib/write_xlsx/worksheet.rb', line 212

def data
  { :sst_id => token }
end

#write_cellObject



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/write_xlsx/worksheet.rb', line 216

def write_cell
  attributes = cell_attributes
  attributes << 't' << 's'
  @worksheet.writer.tag_elements('c', attributes) do
    @worksheet.write_cell_value(token)
  end

  if link_type == 1
    # External link with rel file relationship.
    @worksheet.hlink_count += 1
    @worksheet.hlink_refs <<
      [
       link_type,    row,     col,
       @worksheet.hlink_count, @str, @tip
      ]

    @worksheet.external_hyper_links << [ '/hyperlink', @url, 'External' ]
  elsif link_type
    # External link with rel file relationship.
    @worksheet.hlink_refs << [link_type, row, col, @url, @str, @tip ]
  end
end