summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/axlsx/drawing/pic.rb2
-rw-r--r--lib/axlsx/drawing/scaling.rb4
-rw-r--r--lib/axlsx/drawing/view_3D.rb4
-rw-r--r--lib/axlsx/util/simple_typed_list.rb2
-rw-r--r--lib/axlsx/util/validators.rb10
-rw-r--r--lib/axlsx/workbook/worksheet/row.rb7
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb5
-rw-r--r--test/stylesheet/tc_styles.rb4
-rw-r--r--test/util/tc_simple_typed_list.rb2
-rw-r--r--test/workbook/tc_workbook.rb6
-rw-r--r--test/workbook/worksheet/tc_row.rb5
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb2
12 files changed, 36 insertions, 17 deletions
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb
index 275a6d06..5a418df0 100644
--- a/lib/axlsx/drawing/pic.rb
+++ b/lib/axlsx/drawing/pic.rb
@@ -53,7 +53,7 @@ module Axlsx
attr_reader :hyperlink
# Picture opacity
- # @return [Fixnum]
+ # @return [Integer]
attr_reader :opacity
# sets or updates a hyperlink for this image.
diff --git a/lib/axlsx/drawing/scaling.rb b/lib/axlsx/drawing/scaling.rb
index fcbea9f8..4c9d6888 100644
--- a/lib/axlsx/drawing/scaling.rb
+++ b/lib/axlsx/drawing/scaling.rb
@@ -6,7 +6,7 @@ module Axlsx
include Axlsx::OptionsParser
# creates a new Scaling object
- # @option options [Integer, Fixnum] logBase
+ # @option options [Integer] logBase
# @option options [Symbol] orientation
# @option options [Float] max
# @option options [Float] min
@@ -35,7 +35,7 @@ module Axlsx
attr_reader :min
# @see logBase
- def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
+ def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
# @see orientation
def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
# @see max
diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb
index 9c320b4a..55bbc6c3 100644
--- a/lib/axlsx/drawing/view_3D.rb
+++ b/lib/axlsx/drawing/view_3D.rb
@@ -86,12 +86,12 @@ module Axlsx
alias :rAngAx= :r_ang_ax=
# @see perspective
- def perspective=(v)
+ def perspective=(v)
RangeValidator.validate "View3D.perspective", 0, 240, v
@perspective = v
end
- # DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
+ # DataTypeValidator.validate "#{self.class}.perspective", [Integer], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
# Serializes the object
# @param [String] str
diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb
index 95f5b3f2..77bed775 100644
--- a/lib/axlsx/util/simple_typed_list.rb
+++ b/lib/axlsx/util/simple_typed_list.rb
@@ -147,7 +147,7 @@ module Axlsx
# determines if the index is protected
# @param [Integer] index
def protected? index
- return false unless locked_at.is_a? Fixnum
+ return false unless locked_at.is_a? Integer
index < locked_at
end
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index 9c6f34aa..2b4afd8d 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -80,16 +80,16 @@ module Axlsx
end
UINT_VALIDATOR = lambda { |arg| arg.respond_to?(:>=) && arg >= 0 }
-
- # Requires that the value is a Fixnum or Integer and is greater or equal to 0
+
+ # Requires that the value is a Integer and is greater or equal to 0
# @param [Any] v The value validated
- # @raise [ArgumentError] raised if the value is not a Fixnum or Integer value greater or equal to 0
+ # @raise [ArgumentError] raised if the value is not a Integer value greater or equal to 0
# @return [Boolean] true if the data is valid
def self.validate_unsigned_int(v)
DataTypeValidator.validate(:unsigned_int, Integer, v, UINT_VALIDATOR)
end
- # Requires that the value is a Fixnum Integer or Float and is greater or equal to 0
+ # Requires that the value is a Integer or Float and is greater or equal to 0
# @param [Any] v The value validated
# @raise [ArgumentError] raised if the value is not a Fixnun, Integer, Float value greater or equal to 0
# @return [Boolean] true if the data is valid
@@ -104,7 +104,7 @@ module Axlsx
end
# Requires that the value is a form that can be evaluated as a boolean in an xml document.
- # The value must be an instance of Fixnum, String, Integer, Symbol, TrueClass or FalseClass and
+ # The value must be an instance of String, Integer, Symbol, TrueClass or FalseClass and
# it must be one of 0, 1, "true", "false", :true, :false, true, false, "0", or "1"
# @param [Any] v The value validated
def self.validate_boolean(v)
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb
index 078e281f..b394279f 100644
--- a/lib/axlsx/workbook/worksheet/row.rb
+++ b/lib/axlsx/workbook/worksheet/row.rb
@@ -103,6 +103,13 @@ module Axlsx
c
end
+ # sets the color for every cell in this row
+ def color=(color)
+ each_with_index do | cell, index |
+ cell.color = color.is_a?(Array) ? color[index] : color
+ end
+ end
+
# sets the style for every cell in this row
def style=(style)
each_with_index do | cell, index |
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index 1d35b99d..031a081f 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -27,7 +27,7 @@ module Axlsx
yield self if block_given?
end
- serializable_attributes :sheet_id, :name, :state
+ serializable_attributes :sheet_id, :state
# Initalizes page margin, setup and print options
# @param [Hash] options Options passed in from the initializer
@@ -555,7 +555,7 @@ module Axlsx
# @example This would set the first and third column widhts but leave the second column in autofit state.
# ws.column_widths 7.2, nil, 3
# @note For updating only a single column it is probably easier to just set the width of the ws.column_info[col_index].width directly
- # @param [Integer|Float|Fixnum|nil] widths
+ # @param [Integer|Float|nil] widths
def column_widths(*widths)
widths.each_with_index do |value, index|
next if value == nil
@@ -597,6 +597,7 @@ module Axlsx
add_autofilter_defined_name_to_workbook
str << '<sheet '
serialized_attributes str
+ str << ('name="' << name << '" ')
str << ('r:id="' << rId << '"></sheet>')
end
diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb
index 98c8e3ef..eb1680ad 100644
--- a/test/stylesheet/tc_styles.rb
+++ b/test/stylesheet/tc_styles.rb
@@ -133,7 +133,7 @@ class TestStyles < Test::Unit::TestCase
:font_name => "woot font"
}
assert_equal(@styles.parse_font_options {}, nil, "noop if no font keys are set")
- assert_equal(@styles.parse_font_options(:b=>1).class, Fixnum, "return index of font if not :dxf type")
+ assert(@styles.parse_font_options(:b=>1).is_a?(Integer), "return index of font if not :dxf type")
assert_equal(@styles.parse_font_options(:b=>1, :type => :dxf).class, Axlsx::Font, "return font object if :dxf type")
f = @styles.parse_font_options(options.merge(:type => :dxf))
@@ -147,7 +147,7 @@ class TestStyles < Test::Unit::TestCase
def test_parse_fill_options
assert_equal(@styles.parse_fill_options {}, nil, "noop if no fill keys are set")
- assert_equal(@styles.parse_fill_options(:bg_color => "DE").class, Fixnum, "return index of fill if not :dxf type")
+ assert(@styles.parse_fill_options(:bg_color => "DE").is_a?(Integer), "return index of fill if not :dxf type")
assert_equal(@styles.parse_fill_options(:bg_color => "DE", :type => :dxf).class, Axlsx::Fill, "return fill object if :dxf type")
f = @styles.parse_fill_options(:bg_color => "DE", :type => :dxf)
assert(f.fill_type.bgColor.rgb == "FFDEDEDE")
diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb
index 1596ac13..72bd6246 100644
--- a/test/util/tc_simple_typed_list.rb
+++ b/test/util/tc_simple_typed_list.rb
@@ -1,7 +1,7 @@
require 'tc_helper.rb'
class TestSimpleTypedList < Test::Unit::TestCase
def setup
- @list = Axlsx::SimpleTypedList.new Fixnum
+ @list = Axlsx::SimpleTypedList.new Integer
end
def teardown
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index 51dd01f4..ab400db1 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -136,4 +136,10 @@ class TestWorkbook < Test::Unit::TestCase
doc = Nokogiri::XML(@wb.to_xml_string)
assert_equal pivot_table.cache_definition.rId, doc.xpath("//xmlns:pivotCache").first["r:id"]
end
+
+ def test_worksheet_name_is_intact_after_serialized_into_xml
+ sheet = @wb.add_worksheet(:name => '_Example')
+ wb_xml = Nokogiri::XML(@wb.to_xml_string)
+ assert_equal sheet.name, wb_xml.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s
+ end
end
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb
index 808e0138..43e7d23f 100644
--- a/test/workbook/worksheet/tc_row.rb
+++ b/test/workbook/worksheet/tc_row.rb
@@ -27,6 +27,11 @@ class TestRow < Test::Unit::TestCase
r.cells.each { |c| assert_equal(c.style,1) }
end
+ def test_color
+ r = @ws.add_row([1,2,3,4,5])
+ r.color = "FF00FF00"
+ r.cells.each { |c| assert_equal(c.color.rgb, "FF00FF00") }
+ end
def test_index
assert_equal(@row.row_index, @row.worksheet.rows.index(@row))
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index df9da22f..166850e5 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -483,7 +483,7 @@ class TestWorksheet < Test::Unit::TestCase
@ws.column_widths nil, 0.5
assert_equal(@ws.column_info[1].width, 0.5, 'eat my width')
assert_raise(ArgumentError, 'only accept unsigned ints') { @ws.column_widths 2, 7, -1 }
- assert_raise(ArgumentError, 'only accept Integer, Float or Fixnum') { @ws.column_widths 2, 7, "-1" }
+ assert_raise(ArgumentError, 'only accept Integer or Float') { @ws.column_widths 2, 7, "-1" }
end
def test_protect_range