Repository: caxlsx/caxlsx (Ruby)

Issue:
Hyperlinking to a worksheet that has underscores in the name will remove the underscores from the link causing it to not work.
I need to generate a spreadsheet which has several worksheet names that use underscores. It would appear to me that when inputting these names into the hyperlink method(`sheet.add_hyperlink`) it converts it from "snake case" to "camel case" but looking through the code I wasn't able to pinpoint where this was happening. I suspect it may be the "htmlentities" gem that is causing this but some help for investigation would be appreciated.

Here is a simple script which outlines the issue:

```ruby
require 'caxlsx'

output = "test.xlsx"

package = Axlsx::Package.new
workbook = package.workbook

workbook.add_worksheet(name: 'BasicName') do |sheet|
  sheet.add_row ["basic_name_with_underscore"]
  sheet.add_hyperlink(
    location: "'basic_name_with_underscore'!A1",
    target: :sheet,
    ref: 'A1'
  )
end

workbook.add_worksheet(name: "basic_name_with_underscore") do |sheet|
  sheet.add_row ["BasicName"]
  sheet.add_hyperlink(
    location: "'BasicName'!A1",
    target: :sheet,
    ref: 'A1'
  )
end

package.serialize(output)
```

Note how one can click the link in the second worksheet(linking to "BasicName") and it correct links to the first, but the link in the first worksheet(linking to "basic_name_with_underscore") is broken as the hyperlinker is converting the link to the worksheet "BasicNameWithUnderscore" which doesn't exist.


Discussion:
I tested this on Linux and on Windows. Same problem on both platforms.
Thanks @realtradam. Do you have any interest in creating a pull request?
Hi, the problem is here:

https://github.com/caxlsx/caxlsx/blob/333331d54639685046d0aeb11a605a729edba656/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb#L63

It is missing the third parameter, `false`, to prevent camelization of attributes, as per

https://github.com/caxlsx/caxlsx/blob/333331d54639685046d0aeb11a605a729edba656/lib/axlsx/util/serialized_attributes.rb#L63

However, I cannot estimate the side effects of this change.

`location` is not included in `serializable_attributes`, but is passed to the method as an extra field as the second parameter when `target` is not external.

I think this may be a bug. Someone with knowledge should clarify whether if `:display, :tooltip, :ref` are sensitive to camel case values

Thanks for the research @tagliala, I added a PR. All existing tests were unaffected by the suggested change.
PR merged



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3751ff0..b4d110dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 CHANGELOG
 ---------
 - **Unreleased**
+  - [PR #316](https://github.com/caxlsx/caxlsx/pull/316) Prevent camelization of hyperlink locations
 
 
 - **October.30.23**: 4.0.0
diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
index 2195fc6b..f0bef9f0 100644
--- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb
@@ -60,7 +60,7 @@ def relationship
     # @return [String]
     def to_xml_string(str = +'')
       str << '<hyperlink '
-      serialized_attributes str, location_or_id
+      serialized_attributes str, location_or_id, false
       str << '/>'
     end
 


Test patch:
diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
index e4e82e88..f8cd9948 100644
--- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb
+++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
@@ -55,4 +55,12 @@ def test_to_xml_stirng_with_external
     assert_equal(0, doc.xpath("//xmlns:hyperlink[@location='#{@a.location}']").size)
     assert_equal(1, doc.xpath("//xmlns:hyperlink[@r:id='#{@a.relationship.Id}']").size)
   end
+
+  def test_to_xml_string_with_underscores
+    @a.location = "'dummy_sheet_2'!A1"
+    doc = Nokogiri::XML(@ws.to_xml_string)
+
+    assert_equal(1, doc.xpath("//xmlns:hyperlink/@location").size)
+    assert_equal(@a.location, doc.xpath("//xmlns:hyperlink/@location").first.value)
+  end
 end