# -*- coding: utf-8 -*- require 'helper' require 'write_xlsx' require 'stringio' class TestTable12 < Minitest::Test def setup workbook = WriteXLSX.new(StringIO.new) @worksheet = workbook.add_worksheet @format = workbook.add_format end def test_table12 # Set the table properties. @worksheet.add_table( 'C2:F14', { :total_row => 1, :columns => [ {:total_string => 'Total'}, {}, {}, { :total_function => 'count', :format => @format, :formula => '=SUM(Table1[@[Column1]:[Column3]])' } ] } ) @worksheet.__send__(:prepare_tables, 1, {}) table = @worksheet.tables[0] table.__send__(:assemble_xml_file) result = got_to_array(table.instance_variable_get(:@writer).string) assert_equal(expected, result) end def expected expected_to_array( < SUM(Table1[[#This Row],[Column1]:[Column3]])
EOS ) end end