diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 1d35b99d..58eab3a1 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -24,6 +24,7 @@ def initialize(wb, options={}) parse_options options @workbook.worksheets << self @sheet_id = index + 1 + name yield self if block_given? end diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index eb668d7f..379152d5 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -266,6 +266,11 @@ def test_row_style end end + def test_to_sheet_node_xml_string_without_name + doc = Nokogiri::XML(@ws.to_sheet_node_xml_string) + assert_equal(doc.xpath('/sheet/@name').size, 1) + end + def test_to_xml_string_fit_to_page @ws.page_setup.fit_to_width = 1 doc = Nokogiri::XML(@ws.to_xml_string)