Skip to content

Commit

Permalink
Release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
randym committed Aug 12, 2012
1 parent 874fab4 commit fd451cd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/axlsx/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: UTF-8
module Axlsx
# The current version
VERSION="1.2.0"
VERSION="1.2.1"
end
7 changes: 6 additions & 1 deletion lib/axlsx/workbook/worksheet/worksheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def tables
@tables ||= Tables.new self
end

# A typed collection of hyperlinks associated with this worksheet
# @return [WorksheetHyperlinks]
def hyperlinks
@hyperlinks ||= WorksheetHyperlinks.new self
end
Expand Down Expand Up @@ -509,9 +511,12 @@ def relationships
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.
Expand Down
14 changes: 13 additions & 1 deletion lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def target=(target)
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)

Expand All @@ -61,21 +61,33 @@ def #{attr}=(value)
}
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
Expand Down
4 changes: 4 additions & 0 deletions test/workbook/worksheet/tc_worksheet_hyperlink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def test_ref
end

def test_id
@a.target = :external

assert_equal("rId1", @a.id)
@a.target = :internal
assert_equal(nil, @a.id)
end


Expand Down

0 comments on commit fd451cd

Please sign in to comment.