weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.27k stars 253 forks source link

Cannot open xlsx file using rubyXL #435

Closed zakky21 closed 5 months ago

zakky21 commented 1 year ago

I get this error when I create a link to an external file in Excel and try to read it in using rubyXL.

Here is a link to a sample file: samplebook.xlsx

Please tell me how to SKIP specific elements, because if an error occurs, the Excel file cannot be read itself.

error detail:

Unknown child node [xxl21:alternateUrls] for element [externalBook]
halida commented 1 year ago

Same issue here.

akiotajima commented 1 year ago

It happens if the book contains a sheet that was copied from another Excel book. In that case ignoring the attribute was not harmful for other operations.

below is the temporary fix, but I don't think this is the real fix, therefore I don't make pull request

--- /tmp/ooxml_object.rb        2023-03-14 15:16:25.265400045 +0900
+++ vendor/bundle/ruby/2.6.0/gems/rubyXL-3.4.25/lib/rubyXL/objects/ooxml_object.rb      2023-03-14 15:15:51.489420908 +0900
@@ -159,7 +159,9 @@
                             end

           child_node_params = known_child_nodes[child_node_name]
+          next if child_node_params.nil? && child_node_name == 'xxl21:alternateUrls'
           raise "Unknown child node [#{child_node_name}] for element [#{node.name}]" if child_node_params.nil?
+
           parsed_object = child_node_params[:class].parse(child_node, known_namespaces)
           if child_node_params[:is_array] then
             index = parsed_object.index_in_collection

https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/452524b4-b22f-45a9-aac1-81fdd1f1db6c

rockorequin commented 1 year ago

Same issue here, thanks for the temporary workaround patch @akiotajima.