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 | |
| parent | 874fab4140637f3df989c3606364c8dfa1502a6e (diff) | |
| download | caxlsx-fd451cdb2dd1f6305d199054501dd84f716d15ce.tar.gz caxlsx-fd451cdb2dd1f6305d199054501dd84f716d15ce.zip | |
Release prep
| -rw-r--r-- | README.md | 5 | ||||
| -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 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet_hyperlink.rb | 4 |
5 files changed, 27 insertions, 5 deletions
@@ -25,7 +25,7 @@ Axlsx: Office Open XML Spreadsheet Generation **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head. -**Release Date**: August 5th 2012 +**Release Date**: August 12th 2012 If you are working in rails, or with active record see: * http://github.com/randym/acts_as_xlsx @@ -145,8 +145,9 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, #Change log --------- -- **August.?.12**: 1.2.1 +- **August.12.12**: 1.2.1 - Add support for hyperlinks in worksheets + - Fix example that was using old style cell merging with concact. - Fix bug that occurs when calculating the font_size for cells that use a user specified style which does not define sz - **August.5.12**: 1.2.0 - rebuilt worksheet serialization to clean up the code base a bit. 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 diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 66e5eea1..ad993e62 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -33,7 +33,11 @@ class TestWorksheetHyperlink < Test::Unit::TestCase end def test_id + @a.target = :external + assert_equal("rId1", @a.id) + @a.target = :internal + assert_equal(nil, @a.id) end |
