diff options
| author | Randy Morgan <[email protected]> | 2012-08-12 23:42:31 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-08-12 23:42:31 +0900 |
| commit | fd451cdb2dd1f6305d199054501dd84f716d15ce (patch) | |
| tree | d03b2a68a04dd654cf2a516db4c346aa1b26c8f1 /lib | |
| parent | 874fab4140637f3df989c3606364c8dfa1502a6e (diff) | |
| download | caxlsx-fd451cdb2dd1f6305d199054501dd84f716d15ce.tar.gz caxlsx-fd451cdb2dd1f6305d199054501dd84f716d15ce.zip | |
Release prep
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/version.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 7 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb | 14 |
3 files changed, 20 insertions, 3 deletions
diff --git a/lib/axlsx/version.rb b/lib/axlsx/version.rb index 4bffcb8d..bb914f7a 100644 --- a/lib/axlsx/version.rb +++ b/lib/axlsx/version.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 module Axlsx # The current version - VERSION="1.2.0" + VERSION="1.2.1" end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index ea34620a..ea3a0d1a 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -71,6 +71,8 @@ module Axlsx @tables ||= Tables.new self end + # A typed collection of hyperlinks associated with this worksheet + # @return [WorksheetHyperlinks] def hyperlinks @hyperlinks ||= WorksheetHyperlinks.new self end @@ -509,9 +511,12 @@ module Axlsx r end + # identifies the index of an object withing the collections used in generating relationships for the worksheet + # @param [Any] object the object to search for + # @return [Integer] The index of the object def relationships_index_of(object) objects = [tables.to_a, worksheet_comments.comments.to_a, hyperlinks.to_a, worksheet_drawing.drawing].flatten.compact || [] - objects.index(object) || 0 + objects.index(object) end # Returns the cell or cells defined using excel style A1:B3 references. diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb index 64c1949d..5de0a6d2 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb @@ -36,7 +36,7 @@ module Axlsx end # Sets the cell location of this hyperlink in the worksheet - # @param [String|Cell] The string reference or cell that defines where this hyperlink shows in the worksheet. + # @param [String|Cell] cell_reference The string reference or cell that defines where this hyperlink shows in the worksheet. def ref=(cell_reference) cell_reference = cell_reference.r if cell_reference.is_a?(Cell) @@ -61,21 +61,33 @@ module Axlsx } end + # The relationship required by this hyperlink when the taget is :external + # @return [Relationship] def relationship return unless @target == :external Relationship.new HYPERLINK_R, location, :target_mode => :External end + # The id of the relationship for this object + # @return [String] def id + return unless @target == :external "rId#{(@worksheet.relationships_index_of(self)+1)}" end + # Seralize the object + # @param [String] str + # @return [String] def to_xml_string(str='') str << '<hyperlink ' serialization_values.map { |key, value| str << key.to_s << '="' << value.to_s << '" ' } str << '/>' end + # The values to be used in serialization based on the target. + # location should only be specified for non-external targets. + # r:id should only be specified for external targets. + # @return [Hash] def serialization_values h = instance_values.reject { |key, value| !%w(display ref tooltip).include?(key) } if @target == :external |
