# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx' require 'stringio' class TestSparkline07 < Test::Unit::TestCase def setup @workbook = WriteXLSX.new(StringIO.new) @worksheet = @workbook.add_worksheet end def test_sparkline07 @worksheet.instance_variable_set(:@excel_version, 2010) @worksheet.select data = [-2, 2, 3, -1, 0] @worksheet.write('A1', data) @worksheet.write('A2', data) @worksheet.write('A3', data) @worksheet.write('A4', data) @worksheet.write('A5', data) @worksheet.write('A6', data) @worksheet.write('A7', data) # Set up sparklines @worksheet.add_sparkline( { :location => 'F1', :range => 'A1:E1', :type => 'column', :high_point => 1 } ) @worksheet.add_sparkline( { :location => 'F2', :range => 'A2:E2', :type => 'column', :low_point => 1 } ) @worksheet.add_sparkline( { :location => 'F3', :range => 'A3:E3', :type => 'column', :negative_points => 1 } ) @worksheet.add_sparkline( { :location => 'F4', :range => 'A4:E4', :type => 'column', :first_point => 1 } ) @worksheet.add_sparkline( { :location => 'F5', :range => 'A5:E5', :type => 'column', :last_point => 1 } ) @worksheet.add_sparkline( { :location => 'F6', :range => 'A6:E6', :type => 'column', :markers => 1 } ) @worksheet.add_sparkline( { :location => 'F7', :range => 'A7:E7', :type => 'column', :high_point => 1, :low_point => 1, :negative_points => 1, :first_point => 1, :last_point => 1, :markers => 1 } ) # End sparklines @worksheet.assemble_xml_file result = got_to_array(@worksheet.instance_variable_get(:@writer).string) expected = expected_to_array(expected_xml) assert_equal(expected, result) end def expected_xml < -2 2 3 -1 0 -2 2 3 -1 0 -2 2 3 -1 0 -2 2 3 -1 0 -2 2 3 -1 0 -2 2 3 -1 0 -2 2 3 -1 0 Sheet1!A7:E7 F7 Sheet1!A6:E6 F6 Sheet1!A5:E5 F5 Sheet1!A4:E4 F4 Sheet1!A3:E3 F3 Sheet1!A2:E2 F2 Sheet1!A1:E1 F1 EOS end end