OpenXmlPackage
A Ruby implementation of DocumentFormat.OpenXml.Packaging.OpenXmlPackage from Microsoft's Open XML SDK.
Installation
Add this line to your application's Gemfile:
gem 'open_xml_package'
And then execute:
$ bundle
Or install it yourself as:
$ gem install open_xml_package
Usage
Writing
You can assemble an Open XML Package in-memory and then write it to disk:
package = OpenXmlPackage.new
package.add_part "content/document.xml", "<document></document>"
package.add_part "media/image.png", File.open(image_path, "rb", &:read)
package.write_to "~/Desktop/output.zip"
Reading
You can read the contents of an Open XML Package:
OpenXmlPackage.open("~/Desktop/output.zip") do |package|
package.parts.map(&:path) # => ["content/document.xml", "media/image.png"]
end
Contributing
- Fork it ( https://github.com/[my-github-username]/open_xml_package/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request