From fe80334f213e3dc149f560a50d90d09054f519fe Mon Sep 17 00:00:00 2001 From: sato-s Date: Sun, 9 Oct 2016 21:47:10 +0900 Subject: Fix #472: worksheet name with underscore Previously, worksheet name was defined as a serializable_attributes that Axlsx automatically camelize by Axlsx.camel . This cause an unexpected worksheet name convertion. For instance, - "Pie_chart" is converted into "Piechart" - "_example" is converted into "Example" This patch disables an unexpected worksheet name convertion. --- lib/axlsx/workbook/worksheet/worksheet.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 1d35b99d..26be8bd8 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 @@ -597,6 +597,7 @@ module Axlsx add_autofilter_defined_name_to_workbook str << '') end -- cgit v1.2.3 From 5a7e890c40e8ec2f9669eb130721397bc97f0d38 Mon Sep 17 00:00:00 2001 From: sato-s Date: Mon, 14 Nov 2016 17:34:27 +0900 Subject: Test case to check sheet name is intact after serialized to xml --- test/workbook/tc_workbook.rb | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- cgit v1.2.3