excelsioroo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/excelsioroo +5 -0
  2. data/lib/excelsioroo.rb +38 -0
  3. metadata +63 -0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'excelsioroo'
4
+
5
+ Excelsioroo.new(ARGV[0]).get_data ARGV[1], ARGV[2], ARGV[3], ARGV[4]
@@ -0,0 +1,38 @@
1
+ require 'roo'
2
+ require 'json'
3
+
4
+ class Excelsioroo
5
+ attr_reader :spreadsheet
6
+
7
+ def initialize filename, sheet = nil
8
+ @spreadsheet = check_file filename
9
+ sheet = @spreadsheet.sheets.first unless !sheet.nil?
10
+ @spreadsheet.default_sheet = sheet
11
+ end
12
+
13
+ def check_file filename
14
+ case filename
15
+ when /.xls/
16
+ document = Excel.new filename
17
+ when /.xlsx/
18
+ document = Excelx.new filename
19
+ when /.ods/
20
+ document = Openoffice.new filename
21
+ end
22
+ document
23
+ end
24
+
25
+ def get_data start_column, start_row, end_column, end_row
26
+ data, rows = [], []
27
+
28
+ # Traverse the rows and columns
29
+ start_row.to_i.upto end_row.to_i do |row|
30
+ start_column.upto end_column do |column|
31
+ data << "#{@spreadsheet.cell(row, column)} "
32
+ end
33
+ rows << data
34
+ end
35
+ puts JSON.generate(rows)
36
+ end
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: excelsioroo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fernando Briano
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: roo
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.3
30
+ description: A gem to export spreadsheet files data into JSON
31
+ email: fernando@picandocodigo.net
32
+ executables:
33
+ - excelsioroo
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/excelsioroo.rb
38
+ - bin/excelsioroo
39
+ homepage: http://rubygems.org/gems/excelsioroo
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.24
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Excelsioroo
63
+ test_files: []