diff options
| -rw-r--r-- | lib/axlsx/doc_props/app.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/drawing/axis.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/vml_shape.rb | 3 | ||||
| -rw-r--r-- | lib/axlsx/util/simple_typed_list.rb | 13 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 5 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/comment.rb | 6 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 4 | ||||
| -rw-r--r-- | test/doc_props/tc_app.rb | 32 | ||||
| -rw-r--r-- | test/drawing/tc_axis.rb | 12 | ||||
| -rw-r--r-- | test/drawing/tc_chart.rb | 24 | ||||
| -rw-r--r-- | test/drawing/tc_pic.rb | 5 | ||||
| -rw-r--r-- | test/drawing/tc_scatter_chart.rb | 5 | ||||
| -rw-r--r-- | test/stylesheet/tc_table_style.rb | 8 | ||||
| -rw-r--r-- | test/stylesheet/tc_table_style_element.rb | 11 | ||||
| -rw-r--r-- | test/tc_package.rb | 24 | ||||
| -rw-r--r-- | test/util/tc_simple_typed_list.rb | 13 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 10 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_col.rb | 9 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_conditional_formatting.rb | 44 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_row.rb | 5 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet.rb | 6 |
21 files changed, 206 insertions, 39 deletions
diff --git a/lib/axlsx/doc_props/app.rb b/lib/axlsx/doc_props/app.rb index 1b5fc2ad..9f8b318b 100644 --- a/lib/axlsx/doc_props/app.rb +++ b/lib/axlsx/doc_props/app.rb @@ -62,10 +62,10 @@ module Axlsx attr_reader :CharactersWithSpaces # @return [Boolean] Indicates if the document is shared. - attr_reader :ShareDoc + attr_reader :SharedDoc # @return [String] The base for hyper links in the document. - attr_reader :HyperLinkBase + attr_reader :HyperlinkBase # @return [Boolean] Indicates that the hyper links in the document have been changed. attr_reader :HyperlinksChanged diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index 1e16dee6..1cc23448 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -116,7 +116,7 @@ module Axlsx str << '<c:delete val="'<< @delete.to_s << '"/>' str << '<c:axPos val="' << @axPos.to_s << '"/>' str << '<c:majorGridlines>' - if self.gridlines == false + if gridlines == false str << '<c:spPr>' str << '<a:ln>' str << '<a:noFill/>' diff --git a/lib/axlsx/drawing/vml_shape.rb b/lib/axlsx/drawing/vml_shape.rb index d1aaf07e..c4b56237 100644 --- a/lib/axlsx/drawing/vml_shape.rb +++ b/lib/axlsx/drawing/vml_shape.rb @@ -58,6 +58,7 @@ module Axlsx @top_offset = 2 @right_offset = 50 @bottom_offset = 5 + @id = (0...8).map{65.+(rand(25)).chr}.join options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end @@ -99,7 +100,7 @@ module Axlsx def to_xml_string(str ='') str << <<SHAME_ON_YOU -<v:shape id="" type="#_x0000_t202" +<v:shape id="#{@id}" type="#_x0000_t202" style='position:absolute;margin-left:104pt;margin-top:2pt;width:800px;height:27pt;z-index:1;mso-wrap-style:tight' fillcolor="#ffffa1 [80]" o:insetmode="auto"> diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb index 8fc4795a..e3336678 100644 --- a/lib/axlsx/util/simple_typed_list.rb +++ b/lib/axlsx/util/simple_typed_list.rb @@ -155,19 +155,6 @@ module Axlsx str << '</' << el_name << '>' end - # Serializes the list - # If the serialize_as property is set, it is used as the parent node name. - # If the serialize_as property is nil, the first item in the list of allowed_types will be used, having the first letter of the class changed to lower case. - # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. - # @return [String] - def to_xml(xml) - classname = @allowed_types[0].name.split('::').last - el_name = serialize_as || (classname[0,1].downcase + classname[1..-1]) - xml.send(el_name, :count=>@list.size) { - @list.each { |item| item.to_xml(xml) } - } - end - end diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index c58ede3a..2684af75 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -261,9 +261,8 @@ module Axlsx # @return [String] def run_xml_string(str = '') if is_text_run? - data = self.instance_values.reject{|key, value| value == nil } + data = instance_values.reject{|key, value| value == nil || key == 'value' || key == 'type' } keys = data.keys & INLINE_STYLES - keys.delete ['value', 'type'] str << "<r><rPr>" keys.each do |key| case key @@ -272,7 +271,7 @@ module Axlsx when 'color' str << data[key].to_xml_string else - "<" << key.to_s << " val='" << data[key].to_s << "'/>" + str << "<" << key.to_s << " val='" << data[key].to_s << "'/>" end end str << "</rPr>" << "<t>" << value.to_s << "</t></r>" diff --git a/lib/axlsx/workbook/worksheet/comment.rb b/lib/axlsx/workbook/worksheet/comment.rb index f3d19e13..0394d7c8 100644 --- a/lib/axlsx/workbook/worksheet/comment.rb +++ b/lib/axlsx/workbook/worksheet/comment.rb @@ -41,12 +41,6 @@ module Axlsx @vml_shape ||= initialize_vml_shape end - # The index of this comment - # @return [Integer] - def index - @comments.index(self) - end - # # The index of this author in a unique sorted list of all authors in # the comment. diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index dfa7fbdc..66d4b67c 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -482,13 +482,13 @@ module Axlsx page_margins.to_xml_string(str) if @page_margins page_setup.to_xml_string(str) if @page_setup str.concat "<drawing r:id='rId1'></drawing>" if @drawing - unless @tables.empty? + str << '<legacyDrawing r:id="rId1"/>' if @comments.size > 0 + unless @tables.empty? str.concat "<tableParts count='%s'>%s</tableParts>" % [@tables.size, @tables.reduce('') { |memo, obj| memo += "<tablePart r:id='%s'/>" % obj.rId }] end @conditional_formattings.each do |cf| str.concat cf.to_xml_string end - str << '<legacyDrawing r:id="rId1"/>' if @comments.size > 0 str + '</worksheet>' end diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb index bff2bb3d..ec862c37 100644 --- a/test/doc_props/tc_app.rb +++ b/test/doc_props/tc_app.rb @@ -1,9 +1,39 @@ require 'tc_helper.rb' class TestApp < Test::Unit::TestCase + def setup + options = { + :'Template' => 'Foo.xlt', + :'Manager' => 'Penny', + :'Company' => "Bob's Repair", + :'Pages' => 1, + :'Words' => 2, + :'Characters' => 7, + :'PresentationFormat' => 'any', + :'Lines' => 1, + :'Paragraphs' => 1, + :'Slides' => 4, + :'Notes' => 1, + :'TotalTime' => 2, + :'HidddenSlides' => 3, + :'MMClips' => 10, + :'ScaleCrop' => true, + :'LinksUpToDate' => true, + :'CharactersWithSpaces' => 9, + :'SharedDoc' => false, + :'HyperlinkBase' => 'foo', + :'HyperlInksChanged' => false, + :'Application' => 'axlsx', + :'AppVersion' => '1.1.5', + :'DocSecurity' => 0 + } + + @app = Axlsx::App.new options + + end def test_valid_document schema = Nokogiri::XML::Schema(File.open(Axlsx::APP_XSD)) - doc = Nokogiri::XML(Axlsx::App.new.to_xml_string) + doc = Nokogiri::XML(@app.to_xml_string) errors = [] schema.validate(doc).each do |error| errors << error diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 7fe01395..c86d3c50 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -2,7 +2,7 @@ require 'tc_helper.rb' class TestAxis < Test::Unit::TestCase def setup - @axis = Axlsx::Axis.new 12345, 54321 + @axis = Axlsx::Axis.new 12345, 54321, :gridlines => false end def teardown end @@ -48,5 +48,15 @@ class TestAxis < Test::Unit::TestCase assert_raise(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' } assert_nothing_raised("accepts valid crosses") { @axis.gridlines = false } end + + def test_to_xml_string + str = '<?xml version="1.0" encoding="UTF-8"?>' + str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">' + doc = Nokogiri::XML(@axis.to_xml_string(str)) + assert(doc.xpath('//a:noFill')) + assert(doc.xpath("//c:crosses[@val='#{@crosses.to_s}']")) + assert(doc.xpath("//c:crossAx[@val='#{@crossAx.to_s}']")) + assert(doc.xpath("//a:bodyPr[@rot='#{@label_rotation.to_s}']")) + end end diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index 98a72e9c..13c400a3 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -22,11 +22,16 @@ class TestChart < Test::Unit::TestCase @chart.title.text = 'wowzer' assert_equal(@chart.title.text, "wowzer", "the title text via a string") assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.") - @chart.title.cell = @row.cells.first + @chart.title = @row.cells.first assert_equal(@chart.title.text, "one", "the title text was set via cell reference") assert_equal(@chart.title.cell, @row.cells.first) end + def test_to_from_marker_access + assert(@chart.to.is_a?(Axlsx::Marker)) + assert(@chart.from.is_a?(Axlsx::Marker)) + end + def test_style assert_raise(ArgumentError) { @chart.style = 49 } assert_nothing_raised { @chart.style = 2 } @@ -34,16 +39,29 @@ class TestChart < Test::Unit::TestCase end def test_start_at - @chart.start_at 15,25 + @chart.start_at 15, 25 assert_equal(@chart.graphic_frame.anchor.from.col, 15) assert_equal(@chart.graphic_frame.anchor.from.row, 25) - + @chart.start_at @row.cells.first + assert_equal(@chart.graphic_frame.anchor.from.col, 0) + assert_equal(@chart.graphic_frame.anchor.from.row, 0) + @chart.start_at [5,6] + assert_equal(@chart.graphic_frame.anchor.from.col, 5) + assert_equal(@chart.graphic_frame.anchor.from.row, 6) + end def test_end_at @chart.end_at 25, 90 assert_equal(@chart.graphic_frame.anchor.to.col, 25) assert_equal(@chart.graphic_frame.anchor.to.row, 90) + @chart.end_at @row.cells.last + assert_equal(@chart.graphic_frame.anchor.to.col, 2) + assert_equal(@chart.graphic_frame.anchor.to.row, 0) + @chart.end_at [10,11] + assert_equal(@chart.graphic_frame.anchor.to.col, 10) + assert_equal(@chart.graphic_frame.anchor.to.row, 11) + end def test_add_series diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 78750cbd..5fc1f1c3 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -6,7 +6,7 @@ class TestPic < Test::Unit::TestCase @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg" - @image = ws.add_image :image_src => @test_img + @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?" end def teardown @@ -14,11 +14,12 @@ class TestPic < Test::Unit::TestCase def test_initialization assert_equal(@p.workbook.images.first, @image) + assert_equal(@image.file_name, 'image1.jpeg') assert_equal(@image.image_src, @test_img) end def test_hyperlink - assert_equal(@image.hyperlink, nil) + assert_equal(@image.hyperlink.href, "https://github.com/randym") @image.hyperlink = "http://axlsx.blogspot.com" assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com") end diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 30178649..a60bba76 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -22,6 +22,11 @@ class TestScatterChart < Test::Unit::TestCase def teardown end + def test_scatter_style + @chart.scatterStyle = :marker + assert(@chart.scatterStyle == :marker) + assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot } + end def test_initialization assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect") assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect") diff --git a/test/stylesheet/tc_table_style.rb b/test/stylesheet/tc_table_style.rb index 8b219a93..f58a7a0d 100644 --- a/test/stylesheet/tc_table_style.rb +++ b/test/stylesheet/tc_table_style.rb @@ -13,6 +13,10 @@ class TestTableStyle < Test::Unit::TestCase assert_equal(@item.name, "fisher") assert_equal(@item.pivot, nil) assert_equal(@item.table, nil) + ts = Axlsx::TableStyle.new 'price', :pivot => true, :table => true + assert_equal(ts.name, 'price') + assert_equal(ts.pivot, true) + assert_equal(ts.table, true) end def test_name @@ -33,4 +37,8 @@ class TestTableStyle < Test::Unit::TestCase assert_equal(@item.table, true) end + def test_to_xml_string + doc = Nokogiri::XML(@item.to_xml_string) + assert(doc.xpath("//tableStyle[@name='#{@item.name}']")) + end end diff --git a/test/stylesheet/tc_table_style_element.rb b/test/stylesheet/tc_table_style_element.rb index 2e6e763f..9ef54e2f 100644 --- a/test/stylesheet/tc_table_style_element.rb +++ b/test/stylesheet/tc_table_style_element.rb @@ -13,6 +13,10 @@ class TestTableStyleElement < Test::Unit::TestCase assert_equal(@item.type, nil) assert_equal(@item.size, nil) assert_equal(@item.dxfId, nil) + options = { :type => :headerRow, :size => 10, :dxfId => 1 } + + tse = Axlsx::TableStyleElement.new options + options.each { |key, value| assert_equal(tse.send(key.to_sym), value) } end def test_type @@ -32,5 +36,10 @@ class TestTableStyleElement < Test::Unit::TestCase assert_nothing_raised { @item.dxfId = 7 } assert_equal(@item.dxfId, 7) end - + + def test_to_xml_string + doc = Nokogiri::XML(@item.to_xml_string) + @item.type = :headerRow + assert(doc.xpath("//tableStyleElement[@type='#{@item.type.to_s}']")) + end end diff --git a/test/tc_package.rb b/test/tc_package.rb index 5ff358c5..60f5f0a7 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -16,6 +16,9 @@ class TestPackage < Test::Unit::TestCase image.hyperlink.tooltip = "Labeled Link" image.start_at 2, 2 end + ws.add_image :image_src => File.expand_path('../../examples/image1.gif', __FILE__) + ws.add_image :image_src => File.expand_path('../../examples/image1.png', __FILE__) + ws.add_table 'A1:C1' end def test_use_autowidth @@ -63,7 +66,11 @@ class TestPackage < Test::Unit::TestCase def test_validation assert_equal(@package.validate.size, 0, @package.validate) - #how to test for failure? the internal validations on the models are so strict I cant break anthing..... + parts = @package.send(:parts) + workbook = parts.select { |part| part[:entry] =~ /xl\/workbook\.xml/ }.first + workbook[:doc] = workbook[:doc].gsub('definedNames', 'defineNames') + errors = @package.send(:validate_single_doc, workbook[:schema], workbook[:doc] ) + assert_equal(errors.size, 1) end def test_parts @@ -85,7 +92,7 @@ class TestPackage < Test::Unit::TestCase #no mystery parts - assert_equal(p.size, 15) + assert_equal(p.size, 18) end @@ -120,4 +127,17 @@ class TestPackage < Test::Unit::TestCase assert(Axlsx::name_to_indices('A1') == [0,0]) assert(Axlsx::name_to_indices('A100') == [0,99], 'needs to axcept rows that contain 0') end + + def test_to_stream + stream = @package.to_stream + assert(stream.is_a?(StringIO)) + # this is just a roundabout guess for a package as it is build now + # in testing. + assert(stream.size > 80000) + end + + def test_encrypt + # this is no where near close to ready yet + assert(@package.encrypt('your_mom.xlsxl', 'has a password') == false) + end end diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb index 482ea8e3..d74cc9cc 100644 --- a/test/util/tc_simple_typed_list.rb +++ b/test/util/tc_simple_typed_list.rb @@ -61,5 +61,18 @@ class TestSimpleTypedList < Test::Unit::TestCase assert_nothing_raised { @list.delete 0 } assert_nothing_raised { @list.delete 9 } end + + def test_delete + @list.push 1 + assert(@list.size == 1) + @list.delete 1 + assert(@list.empty?) + end + def test_equality + @list.push 1 + @list.push 2 + assert_equal(@list, [1,2]) + + end end diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 6a93fc58..c486a770 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -250,7 +250,15 @@ class TestCell < Test::Unit::TestCase c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) assert_equal(c_xml.xpath("/c[@s=1]").size, 1) end - + def test_to_xml_string_with_run + @c.b = true + @c.type = :string + @c.value = "a" + @c.font_name = 'arial' + @c.color = 'FF0000' + c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) + assert(c_xml.xpath("//b")) + end def test_to_xml_string_formula p = Axlsx::Package.new ws = p.workbook.add_worksheet do |ws| diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb index b28e26e9..3eb033be 100644 --- a/test/workbook/worksheet/tc_col.rb +++ b/test/workbook/worksheet/tc_col.rb @@ -6,6 +6,13 @@ class TestCol < Test::Unit::TestCase @col = Axlsx::Col.new 1, 1 end + def test_initialize + options = { :width => 12, :collapsed => true, :hidden => true, :outlineLevel => 1, :phonetic => true, :style => 1} + + col = Axlsx::Col.new 0, 0, options + options.each{ |key, value| assert_equal(col.send(key.to_sym), value) } + end + def test_min_max_required assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new } assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new nil, nil } @@ -53,6 +60,8 @@ class TestCol < Test::Unit::TestCase def test_style assert_equal(@col.style, nil) + @col.style = 1 + assert_equal(@col.style, 1) #TODO check that the style specified is actually in the styles xfs collection end diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb index 6b2c6c3b..087fd40e 100644 --- a/test/workbook/worksheet/tc_conditional_formatting.rb +++ b/test/workbook/worksheet/tc_conditional_formatting.rb @@ -15,6 +15,50 @@ class TestConditionalFormatting < Test::Unit::TestCase assert_equal("AA1:AB100", optioned.sqref) assert_equal([1, 2], optioned.rules) end + def test_add_as_rule + + color_scale = Axlsx::ColorScale.new do |cs| + cs.colors.first.rgb = "FFDFDFDF" + cs.colors.last.rgb = "FF00FF00" + cs.value_objects.first.type = :percentile + cs.value_objects.first.val = 5 + end + + data_bar = Axlsx::DataBar.new :color => "FFFF0000" + icon_set = Axlsx::IconSet.new :iconSet => "5Rating" + cfr = Axlsx::ConditionalFormattingRule.new( { :type => :containsText, :text => "TRUE", + :dxfId => 0, :priority => 1, + :formula => 'NOT(ISERROR(SEARCH("FALSE",AB1)))', + :color_scale => color_scale, + :data_bar => data_bar, + :icon_set => icon_set}) + + assert(cfr.data_bar.is_a?(Axlsx::DataBar)) + assert(cfr.icon_set.is_a?(Axlsx::IconSet)) + assert(cfr.color_scale.is_a?(Axlsx::ColorScale)) + cfs = @ws.add_conditional_formatting( "B2:B2", [cfr]) + doc = Nokogiri::XML.parse(cfs.last.to_xml_string) + assert_equal(1, doc.xpath(".//conditionalFormatting[@sqref='B2:B2']//cfRule[@type='containsText'][@dxfId=0][@priority=1]").size) + assert doc.xpath(".//conditionalFormatting//cfRule[@type='containsText'][@dxfId=0][@priority=1]//formula='NOT(ISERROR(SEARCH(\"FALSE\",AB1)))'") + + cfs.last.rules.last.type = :colorScale + doc = Nokogiri::XML.parse(cfs.last.to_xml_string) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//colorScale//cfvo").size, 2) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//colorScale//color").size, 2) + + cfs.last.rules.last.type = :dataBar + doc = Nokogiri::XML.parse(cfs.last.to_xml_string) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//dataBar").size, 1) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//dataBar//cfvo").size, 2) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//dataBar//color[@rgb='FFFF0000']").size, 1) + + cfs.last.rules.last.type = :iconSet + doc = Nokogiri::XML.parse(cfs.last.to_xml_string) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//iconSet//cfvo").size, 3) + assert_equal(doc.xpath(".//conditionalFormatting//cfRule//iconSet[@iconSet='5Rating']").size, 1) + + end + def test_add_as_hash diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index 064ca5d0..d6835f05 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -91,6 +91,11 @@ class TestRow < Test::Unit::TestCase end def test_to_xml_string + @row.height = 20 + @row.style = 1 + @row.outlineLevel = 2 + @row.collapsed = true + @row.hidden = true r_s_xml = Nokogiri::XML(@row.to_xml_string(0, '')) assert_equal(r_s_xml.xpath(".//row[@r=1]").size, 1) end diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index e33506cd..5366ab3d 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -180,6 +180,12 @@ class TestWorksheet < Test::Unit::TestCase end assert_equal(@ws.rows[1].cells[0].style, 0) assert_equal(@ws.rows[2].cells[1].style, 0) + @ws.row_style( 1..2, 1, :col_offset => 2) + @ws.rows[(1..2)].each do |r| + r.cells[(2..-1)].each do |c| + assert_equal(c.style, 1) + end + end end def test_to_xml_string_fit_to_page |
