lib/writer/workbook_writer.rb in rubyXL-1.1.3 vs lib/writer/workbook_writer.rb in rubyXL-1.1.4
- old
+ new
@@ -42,19 +42,15 @@
index.upto(@workbook.external_links.size-1) do |id|
xml.externalReference('r:id'=>"rId#{id+index}")
end
}
end
- # unless @workbook.definedNames.nil?
- # xml.definedNames {
- # @workbook.definedNames.each do |name|
- # xml.definedName('name'=>name[:attributes][:name]) {
- # # name[:]
- # }
- # end
- # }
- # end
+
+ # nokogiri builder creates CDATA tag around content,
+ # using .text creates "html safe" < and > in place of < and >
+ # xml to hash method does not seem to function well for this particular piece of xml
+ xml.cdata @workbook.defined_names.to_s
#TODO see if this changes with formulas
#attributes out of order here
xml.calcPr('calcId'=>'130407', 'concurrentCalc'=>'0')
xml.extLst {
@@ -64,12 +60,18 @@
}
}
}
end
contents = builder.to_xml
+ p contents
contents = contents.gsub(/\n/,'')
contents = contents.gsub(/>(\s)+</,'><')
+ contents = contents.gsub(/<!\[CDATA\[(.*)\]\]>/,'\1')
contents = contents.sub(/<\?xml version=\"1.0\"\?>/,'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+"\n")
+ puts '
+
+ '
+ puts contents
contents
end
end
end