Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
require 'C:\Program Files\Open XML Format SDK\V2.0\\lib\DocumentFormat.OpenXml.dll'
include DocumentFormat::OpenXml::Packaging
include DocumentFormat::OpenXml::Spreadsheet
doc ='docs/single-cell.xlsx', false)
a = doc.workbook_part.workbook.method(:get_first_child).of(Sheets).call
puts a
# -> DocumentFormat.OpenXml.Spreadsheet.Sheets
b = a.method(:elements).of(Sheet).call
puts b
# -> DocumentFormat.OpenXml.OpenXmlElementList+<OfType>d__0`1[DocumentFormat.OpenXml.Spreadsheet.Sheet]
# b.first or anything similar fails
# b.methods shows a .to_a
puts b.to_a.first # woot!
# -> DocumentFormat.OpenXml.Spreadsheet.Sheet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment