Giter Site home page Giter Site logo

pat / parseexcel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hmcgowan/parseexcel

2.0 3.0 2.0 181 KB

Spreadsheet::ParseExcel - Get information from an Excel file. Modifying to port font support

Home Page: http://raa.ruby-lang.org/project/parseexcel/

License: GNU Lesser General Public License v2.1

Ruby 100.00%

parseexcel's Introduction

Note by Pat: The original author has since merged this code into the spreadsheet gem. However, that's released as GPL, so I'm personally going to use this instead. It seems to do the job. Don't blame me for the old documentation though!

I'm using Bundler, so that makes it easy to refer to this repository instead of the existing gem.

  gem 'parseexcel',
    :git    => 'git://github.com/pat/parseexcel.git',
    :branch => 'master'

I don't maintain the gem, so if you want my changes, you're going to have to grab them from Github.

And below is the original instructions.



Spreadsheet::ParseExcel - Get information from an Excel file.
============
Version: 0.5.2
Date: 2007-07-19

Short Description:
Spreadsheet::ParseExcel allows you to get information out of a 
simple Excel file
This Package is an - as of today incomplete - translation of 
Kawai Takanoris Perl-Module.


Requirements
------------

  * ruby 1.8
	
Install
-------

  De-Compress archive and enter its top directory.
  Then type:

    $ ruby install.rb config
    $ ruby install.rb setup
   ($ su)
    # ruby install.rb install

  You can also install files into your favorite directory
  by supplying install.rb with some options. Try "ruby install.rb --help".
  More information can be found in the redistributed file usage-en.txt


Usage
-----
#!/usr/bin/env ruby

require 'parseexcel'

# your first step is always reading in the file.
# that gives you a workbook-object, which has one or more worksheets,
# just like in Excel you have the possibility of multiple worksheets.
workbook = Spreadsheet::ParseExcel.parse(path_to_file)

# usually, you want the first worksheet:
worksheet = workbook.worksheet(0)

# now you can either iterate over all rows, skipping the first number of
# rows (in case you know they just contain column headers)
skip = 2
worksheet.each(skip) { |row|
  # a row is actually just an Array of Cells..
  first_cell = row.at(0)

  # how you get data out of the cell depends on what datatype you
  # expect:

  # if you expect a String, you can pass an encoding and (iconv
  # required) the content of the cell will be converted.
  str = row.at(1).to_s('latin1')

  # if you expect a Float:
  float = row.at(2).to_f

  # if you expect an Integer:
  int = row.at(3).to_i

  # if you expect a Date:
  date = row.at(4).date

  # ParseExcel makes a guess at what Datatype a cell has. At the moment,
        # possible values are: :date, :numeric, :text
        celltype = first_cell.type
}

# if you know exactly which row your data resides in, you may just
# retrieve that row, which is again simply an Array of Cells
row = worksheet.row(26)


License
-------

	LGPL

	
URL: http://download.ywesee.com/parseexcel
Author: Hannes Wyss <[email protected]>

parseexcel's People

Contributors

pat avatar samullen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.