### Install Creek Ruby Gem via Command Line Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Instructions to install the Creek gem globally using the `gem` command. This makes the gem available for use in any Ruby project. ```Shell gem install creek ``` -------------------------------- ### Set Up Creek Development Environment Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Instructions for setting up the development environment for the Creek gem, including installing Bundler and gem dependencies, and running the test suite. ```Shell gem install bundler bundle install ``` ```Shell rake ``` ```Shell bundle exec rspec --tag remote ``` -------------------------------- ### Bypass File Extension Check in Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Demonstrates how to initialize a `Creek::Book` instance while bypassing the default file extension check, useful for files with non-standard extensions like `.zip` that contain Excel content. ```Ruby path = 'sample-as-zip.zip' Creek::Book.new path, :check_file_extension => false ``` -------------------------------- ### Parse Remote Excel Files with Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Demonstrates how to open and parse an Excel file located at a remote URL by passing the `remote: true` option to `Creek::Book.new`. ```Ruby remote_url = 'http://dev-builds.libreoffice.org/tmp/test.xlsx' Creek::Book.new remote_url, remote: true ``` -------------------------------- ### Parse Excel File and Iterate Rows with Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Demonstrates how to open an Excel file using `Creek::Book` and iterate through its sheets and rows. It shows different methods for accessing row data: `rows` (with A1-style keys), `simple_rows` (with A-style keys), and their `_with_meta_data` counterparts. It also shows how to access sheet properties like `state`, `name`, and `rid`. ```Ruby require 'creek' creek = Creek::Book.new 'spec/fixtures/sample.xlsx' sheet = creek.sheets[0] sheet.rows.each do |row| puts row # => {"A1"=>"Content 1", "B1"=>nil, "C1"=>nil, "D1"=>"Content 3"} end sheet.simple_rows.each do |row| puts row # => {"A"=>"Content 1", "B"=>nil, "C"=>nil, "D"=>"Content 3"} end sheet.rows_with_meta_data.each do |row| puts row # => {"collapsed"=>"false", "customFormat"=>"false", "customHeight"=>"true", "hidden"=>"false", "ht"=>"12.1", "outlineLevel"=>"0", "r"=>"1", "cells"=>{"A1"=>"Content 1", "B1"=>nil, "C1"=>nil, "D1"=>"Content 3"}} end sheet.simple_rows_with_meta_data.each do |row| puts row # => {"collapsed"=>"false", "customFormat"=>"false", "customHeight"=>"true", "hidden"=>"false", "ht"=>"12.1", "outlineLevel"=>"0", "r"=>"1", "cells"=>{"A"=>"Content 1", "B"=>nil, "C"=>nil, "D"=>"Content 3"}} end sheet.state # => 'visible' sheet.name # => 'Sheet1' sheet.rid # => 'rId2' ``` -------------------------------- ### Parse Uploaded Files in Rails with Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Shows how to integrate Creek into a Rails controller to parse uploaded files directly from `params[:file]`. It uses `check_file_extension: false` to handle temporary file paths without requiring explicit file upload gems. ```Ruby # Import endpoint in Rails controller def import file = params[:file] Creek::Book.new file.path, check_file_extension: false end ``` -------------------------------- ### Add Creek Gem to Ruby Gemfile Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Instructions to include the Creek gem as a dependency in a Ruby on Rails or other Bundler-managed project by adding it to the `Gemfile`. ```Ruby gem 'creek' ``` -------------------------------- ### Parse Excel Files with Images using Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Illustrates how to configure Creek to parse images embedded in Excel files. The `with_images` method must be called before iterating over rows to preload image information, which will then be returned as `Pathname` objects within the row data or via `images_at`. ```Ruby sheet.with_images.rows.each do |row| puts row # => {"A1"=>[#], "B2"=>"Fluffy"} end ``` ```Ruby puts sheet.images_at('A1') # => [#] # no images in a cell puts sheet.images_at('C1') # => nil ``` -------------------------------- ### Map Excel Cells by Header Names with Creek Source: https://github.com/pythonicrubyist/creek/blob/master/README.md Explains how to configure Creek to map cell values using header column names instead of default A1-style cell names. This is enabled by passing `with_headers: true` during `Creek::Book` initialization and is only compatible with the `simple_rows` method. ```Ruby creek = Creek::Book.new file.path, with_headers: true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.