simple-spreadsheet 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ spec/.DS_Store
3
3
  objects/
4
4
  logs/
5
5
  lib/.DS_Store
6
- .DS_Store
6
+ .DS_Store
7
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
data/Gemfile.lock CHANGED
@@ -1,44 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-spreadsheet (0.1.0)
5
- roo (= 1.10.1)
4
+ simple-spreadsheet (0.1.5)
5
+ roo (= 1.11.2)
6
6
  rubyXL (= 1.2.5)
7
7
  spreadsheet (= 0.6.5.9)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- choice (0.1.6)
13
12
  diff-lcs (1.1.3)
14
- faraday (0.8.1)
15
- multipart-post (~> 1.1)
16
- google-spreadsheet-ruby (0.3.0)
17
- google_drive (>= 0.3.0)
18
- google_drive (0.3.0)
19
- nokogiri (>= 1.4.4, != 1.5.2, != 1.5.1)
20
- oauth (>= 0.3.6)
21
- oauth2 (>= 0.5.0)
22
- httpauth (0.1)
23
- log4r (1.1.10)
24
- multi_json (1.3.6)
25
- multipart-post (1.1.5)
26
- nokogiri (1.5.4)
27
- oauth (0.4.6)
28
- oauth2 (0.7.1)
29
- faraday (~> 0.8)
30
- httpauth (~> 0.1)
31
- multi_json (~> 1.0)
32
- rack (~> 1.4)
33
- rack (1.4.1)
13
+ mini_portile (0.5.1)
14
+ nokogiri (1.6.0)
15
+ mini_portile (~> 0.5.0)
34
16
  rake (0.9.2.2)
35
- roo (1.10.1)
36
- choice (>= 0.1.4)
37
- google-spreadsheet-ruby (>= 0.1.5)
38
- nokogiri (>= 1.5.0)
39
- rubyzip (>= 0.9.4)
17
+ roo (1.11.2)
18
+ nokogiri
19
+ rubyzip
40
20
  spreadsheet (> 0.6.4)
41
- todonotes (>= 0.1.0)
42
21
  rspec (2.6.0)
43
22
  rspec-core (~> 2.6.0)
44
23
  rspec-expectations (~> 2.6.0)
@@ -47,13 +26,11 @@ GEM
47
26
  rspec-expectations (2.6.0)
48
27
  diff-lcs (~> 1.1.2)
49
28
  rspec-mocks (2.6.0)
50
- ruby-ole (1.2.11.3)
29
+ ruby-ole (1.2.11.7)
51
30
  rubyXL (1.2.5)
52
- rubyzip (0.9.8)
31
+ rubyzip (0.9.9)
53
32
  spreadsheet (0.6.5.9)
54
33
  ruby-ole (>= 1.0)
55
- todonotes (0.1.0)
56
- log4r
57
34
 
58
35
  PLATFORMS
59
36
  ruby
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Simple Spreadsheet
1
+ # Simple Spreadsheet [![Build Status](https://secure.travis-ci.org/zenkay/simple-spreadsheet.png?branch=master)](http://travis-ci.org/zenkay/simple-spreadsheet)
2
2
 
3
3
  Recently I wrote a module to import raw data from Excel-like files to database and export it in various formats. To accomplish this i have to use different gems with different usage patterns so I decide to wrap them in a single simple gem. This is a spreadsheet reader and writer that (will) supports common formats: CSV (.csv), Excel (.xls, .xlsx), Open-office (.ods) and Google (online).
4
4
 
@@ -34,6 +34,7 @@ Supported formats:
34
34
 
35
35
  <table>
36
36
  <tr>
37
+ <th></th>
37
38
  <th>Excel (.xls)</th>
38
39
  <th>Excelx (.xlsx)</th>
39
40
  <th>Openoffice (.ods)</th>
@@ -42,6 +43,7 @@ Supported formats:
42
43
  <th>CSV Tab Separated</th>
43
44
  </tr>
44
45
  <tr>
46
+ <td>Reading whole file</td>
45
47
  <td>Yes</td>
46
48
  <td>Yes</td>
47
49
  <td>Yes</td>
@@ -49,6 +51,15 @@ Supported formats:
49
51
  <td>Yes</td>
50
52
  <td>Yes</td>
51
53
  </tr>
54
+ <tr>
55
+ <td>Reading line by line</td>
56
+ <td>Yes</td>
57
+ <td>-</td>
58
+ <td>-</td>
59
+ <td>Yes</td>
60
+ <td>Yes</td>
61
+ <td>Yes</td>
62
+ </tr>
52
63
  </table>
53
64
 
54
65
 
@@ -92,7 +103,10 @@ s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvx")
92
103
  ```ruby
93
104
  require "simple-spreadsheet"
94
105
 
106
+ # specify format
95
107
  s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvt")
108
+ # use .tsv
109
+ s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.tsv")
96
110
  ```
97
111
 
98
112
  ## Future plans
@@ -1,11 +1,12 @@
1
1
  require "simple-spreadsheet/version"
2
+ require 'roo'
2
3
 
3
4
  module SimpleSpreadsheet
4
-
5
+
5
6
  require 'simple-spreadsheet/modules/roo_module'
6
-
7
+
7
8
  class Workbook
8
-
9
+
9
10
  def self.read(file, ext = nil)
10
11
  ext = File.extname(file) if ext.nil?
11
12
  case ext
@@ -19,60 +20,61 @@ module SimpleSpreadsheet
19
20
  return CsvReader.new(file)
20
21
  when '.csvx'
21
22
  return CsvxReader.new(file)
22
- when '.csvt'
23
+ when '.csvt', '.tsv'
23
24
  return CsvtReader.new(file)
24
25
  else
25
26
  return nil
26
27
  end
27
28
  end
28
29
 
29
- def self.edit(file, ext = nil)
30
- ext = File.extname(file) if ext.nil?
31
- case ext
32
- when '.xls'
33
- ExcelEditor.new(file)
34
- when '.xlsx'
35
- ExcelxEditor.new(file)
36
- when '.ods'
37
- OpenofficeEditor.new(file)
38
- when '.csv'
39
- CsvEditor.new(file)
40
- when '.csvz'
41
- return CsvzEditor.new(file)
42
- when '.csvt'
43
- return CsvtEditor.new(file)
44
- else
45
- return nil
46
- end
47
- end
30
+ # def self.edit(file, ext = nil)
31
+ # ext = File.extname(file) if ext.nil?
32
+ # case ext
33
+ # when '.xls'
34
+ # ExcelEditor.new(file)
35
+ # when '.xlsx'
36
+ # ExcelxEditor.new(file)
37
+ # when '.ods'
38
+ # OpenofficeEditor.new(file)
39
+ # when '.csv'
40
+ # CsvEditor.new(file)
41
+ # when '.csvz'
42
+ # return CsvzEditor.new(file)
43
+ # when '.csvt'
44
+ # return CsvtEditor.new(file)
45
+ # else
46
+ # return nil
47
+ # end
48
+ # end
49
+ #
50
+ # def self.write(file, ext = nil)
51
+ # ext = File.extname(file) if ext.nil?
52
+ # case ext
53
+ # when '.xls'
54
+ # ExcelWriter.new(file)
55
+ # when '.xlsx'
56
+ # ExcelxWriter.new(file)
57
+ # when '.ods'
58
+ # OpenofficeWriter.new(file)
59
+ # when '.csv'
60
+ # CsvWriter.new(file)
61
+ # when '.csvz'
62
+ # return CsvzWriter.new(file)
63
+ # when '.csvt'
64
+ # return CsvtWriter.new(file)
65
+ # else
66
+ # return nil
67
+ # end
68
+ # end
48
69
 
49
- def self.write(file, ext = nil)
50
- ext = File.extname(file) if ext.nil?
51
- case ext
52
- when '.xls'
53
- ExcelWriter.new(file)
54
- when '.xlsx'
55
- ExcelxWriter.new(file)
56
- when '.ods'
57
- OpenofficeWriter.new(file)
58
- when '.csv'
59
- CsvWriter.new(file)
60
- when '.csvz'
61
- return CsvzWriter.new(file)
62
- when '.csvt'
63
- return CsvtWriter.new(file)
64
- else
65
- return nil
66
- end
67
- end
68
-
69
70
  end
70
-
71
+
71
72
  # General
72
73
  require 'simple-spreadsheet/generic_sheet'
73
74
 
74
75
  # Extendend classes
75
76
  require 'simple-spreadsheet/classes/excel_extended'
77
+ require 'simple-spreadsheet/classes/excelx_extended'
76
78
  require 'simple-spreadsheet/classes/csv_extended'
77
79
  require 'simple-spreadsheet/classes/csvx_extended'
78
80
  require 'simple-spreadsheet/classes/csvt_extended'
@@ -107,10 +109,13 @@ module SimpleSpreadsheet
107
109
 
108
110
  # .csvt (CSV)
109
111
  require 'simple-spreadsheet/readers/csvt_reader'
110
-
112
+
111
113
  end
112
114
 
113
115
  # Gems
114
116
  require 'roo'
115
- require 'iconv'
117
+
118
+ if RUBY_VERSION < '1.9'
119
+ require 'iconv'
120
+ end
116
121
 
@@ -1,64 +1,11 @@
1
- require 'roo/generic_spreadsheet'
2
- require 'roo/csv'
1
+ class CsvExtended < Roo::Csv
2
+
3
+ def foreach(sheet = nil, &block)
4
+ index = 1
5
+ CSV.foreach(@filename, col_sep: ",") do |row|
6
+ yield(row, index)
7
+ index += 1
8
+ end
9
+ end
3
10
 
4
- class CsvExtended < Csv
5
- # def read_cells(sheet=nil)
6
- # sheet = @default_sheet unless sheet
7
- # @cell_type = {} unless @cell_type
8
- # @cell = {} unless @cell
9
- # @first_row[sheet] = 1
10
- # @last_row[sheet] = 0
11
- # @first_column[sheet] = 1
12
- # @last_column[sheet] = 1
13
- # rownum = 1
14
- # CSV.foreach(@filename) do |row|
15
- # row.each_with_index do |elem,i|
16
- # @cell[[rownum,i+1]] = cell_postprocessing rownum,i+1, elem
17
- # @cell_type[[rownum,i+1]] = celltype_class @cell[[rownum,i+1]]
18
- # if i+1 > @last_column[sheet]
19
- # @last_column[sheet] += 1
20
- # end
21
- # end
22
- # rownum += 1
23
- # @last_row[sheet] += 1
24
- # end
25
- # @cells_read[sheet] = true
26
- # #-- adjust @first_row if neccessary
27
- # loop do
28
- # if !row(@first_row[sheet]).any? and @first_row[sheet] < @last_row[sheet]
29
- # @first_row[sheet] += 1
30
- # else
31
- # break
32
- # end
33
- # end
34
- # #-- adjust @last_row if neccessary
35
- # loop do
36
- # if !row(@last_row[sheet]).any? and @last_row[sheet] and
37
- # @last_row[sheet] > @first_row[sheet]
38
- # @last_row[sheet] -= 1
39
- # else
40
- # break
41
- # end
42
- # end
43
- # #-- adjust @first_column if neccessary
44
- # loop do
45
- # if !column(@first_column[sheet]).any? and
46
- # @first_column[sheet] and
47
- # @first_column[sheet] < @last_column[sheet]
48
- # @first_column[sheet] += 1
49
- # else
50
- # break
51
- # end
52
- # end
53
- # #-- adjust @last_column if neccessary
54
- # loop do
55
- # if !column(@last_column[sheet]).any? and
56
- # @last_column[sheet] and
57
- # @last_column[sheet] > @first_column[sheet]
58
- # @last_column[sheet] -= 1
59
- # else
60
- # break
61
- # end
62
- # end
63
- # end
64
11
  end
@@ -1,7 +1,13 @@
1
- require 'roo/generic_spreadsheet'
2
- require 'roo/csv'
1
+ class CsvtExtended < Roo::Csv
2
+
3
+ def foreach(sheet = nil, &block)
4
+ index = 1
5
+ CSV.foreach(@filename, col_sep: "\t") do |row|
6
+ yield(row, index)
7
+ index += 1
8
+ end
9
+ end
3
10
 
4
- class CsvtExtended < Csv
5
11
  def read_cells(sheet=nil)
6
12
  sheet = @default_sheet unless sheet
7
13
  @cell_type = {} unless @cell_type
@@ -1,7 +1,13 @@
1
- require 'roo/generic_spreadsheet'
2
- require 'roo/csv'
1
+ class CsvxExtended < Roo::Csv
2
+
3
+ def foreach(sheet = nil, &block)
4
+ index = 1
5
+ CSV.foreach(@filename, col_sep: ";") do |row|
6
+ yield(row, index)
7
+ index += 1
8
+ end
9
+ end
3
10
 
4
- class CsvxExtended < Csv
5
11
  def read_cells(sheet=nil)
6
12
  sheet = @default_sheet unless sheet
7
13
  @cell_type = {} unless @cell_type
@@ -1,37 +1,37 @@
1
- require 'roo/generic_spreadsheet'
2
- require 'roo/excel'
1
+ class ExcelExtended < Roo::Excel
2
+
3
+ def foreach(sheet=nil, &block)
4
+ sheet = @default_sheet unless sheet
5
+ raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
6
+ raise RangeError unless self.sheets.include? sheet
7
+
8
+ if @cells_read[sheet]
9
+ raise "sheet #{sheet} already read"
10
+ end
11
+
12
+ worksheet = @workbook.worksheet(sheet_no(sheet))
13
+ row_index=1
14
+ worksheet.each(0) do |row|
15
+ row_content = []
16
+ (0..row.size).each do |cell_index|
17
+ cell = row.at(cell_index)
18
+ next if cell.nil? #skip empty cells
19
+ next if cell.class == Spreadsheet::Formula && cell.value.nil? # skip empty formula cells
20
+ if date_or_time?(row, cell_index)
21
+ vt, v = read_cell_date_or_time(row, cell_index)
22
+ else
23
+ vt, v = read_cell(row, cell_index)
24
+ end
25
+ formula = tr = nil #TODO:???
26
+ col_index = cell_index + 1
27
+ font = row.format(cell_index).font
28
+ font.extend(ExcelFontExtensions)
29
+ # set_cell_values(sheet,row_index,col_index,0,v,vt,formula,tr,font)
30
+ row_content << v
31
+ end #row
32
+ yield(row_content, row_index)
33
+ row_index += 1
34
+ end # worksheet
35
+ end
3
36
 
4
- class ExcelExtended < Excel
5
- # def read_cells(sheet=nil)
6
- # sheet = @default_sheet unless sheet
7
- # raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
8
- # raise RangeError unless self.sheets.include? sheet
9
- #
10
- # if @cells_read[sheet]
11
- # raise "sheet #{sheet} already read"
12
- # end
13
- #
14
- # worksheet = @workbook.worksheet(sheet_no(sheet))
15
- # row_index=1
16
- # worksheet.each(0) do |row|
17
- # (0..row.size).each do |cell_index|
18
- # cell = row.at(cell_index)
19
- # next if cell.nil? #skip empty cells
20
- # next if cell.class == Spreadsheet::Formula && cell.value.nil? # skip empty formula cells
21
- # if date_or_time?(row, cell_index)
22
- # vt, v = read_cell_date_or_time(row, cell_index)
23
- # else
24
- # vt, v = read_cell(row, cell_index)
25
- # end
26
- # formula = tr = nil #TODO:???
27
- # col_index = cell_index + 1
28
- # font = row.format(cell_index).font
29
- # font.extend(ExcelFontExtensions)
30
- # set_cell_values(sheet,row_index,col_index,0,v,vt,formula,tr,font)
31
- # end #row
32
- # row_index += 1
33
- # end # worksheet
34
- # @cells_read[sheet] = true
35
- # end
36
-
37
37
  end
@@ -0,0 +1,117 @@
1
+ class ExcelxExtended < Roo::Excelx
2
+
3
+ def foreach(sheet = nil, &block)
4
+ sheet = @default_sheet unless sheet
5
+ sheet_found = false
6
+ raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
7
+ raise RangeError unless self.sheets.include? sheet
8
+ n = self.sheets.index(sheet)
9
+ row_index = 1
10
+ @sheet_doc[n].xpath("//*[local-name()='c']").each do |c|
11
+ s_attribute = c['s'].to_i # should be here
12
+ # c: <c r="A5" s="2">
13
+ # <v>22606</v>
14
+ # </c>, format: , tmp_type: float
15
+ if c['t'] == 's'
16
+ tmp_type = :shared
17
+ elsif c['t'] == 'b'
18
+ tmp_type = :boolean
19
+ # 2011-02-25 BEGIN
20
+ elsif c['t'] == 'str'
21
+ tmp_type = :string
22
+ # 2011-02-25 END
23
+ # 2011-09-15 BEGIN
24
+ elsif c['t'] == 'inlineStr'
25
+ tmp_type = :inlinestr
26
+ # 2011-09-15 END
27
+ else
28
+ s_attribute = c['s'].to_i
29
+ format = attribute2format(s_attribute)
30
+ tmp_type = format2type(format)
31
+ end
32
+ formula = nil
33
+ row_content = []
34
+ c.children.each do |cell|
35
+ # 2011-09-15 BEGIN
36
+ if cell.name == 'is'
37
+ cell.children.each do |is|
38
+ if is.name == 't'
39
+ inlinestr_content = is.content
40
+ vt = :string
41
+ str_v = inlinestr_content
42
+ excelx_type = :string
43
+ y, x = GenericSpreadsheet.split_coordinate(c['r'])
44
+ v = nil
45
+ tr=nil #TODO: ???s
46
+ excelx_value = inlinestr_content #cell.content
47
+ # set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v,excelx_type,excelx_value,s_attribute)
48
+ puts v
49
+ row_content << v
50
+ end
51
+ end
52
+ end
53
+ # 2011-09-15 END
54
+ if cell.name == 'f'
55
+ formula = cell.content
56
+ end
57
+ if cell.name == 'v'
58
+ if tmp_type == :time or tmp_type == :datetime
59
+ if cell.content.to_f >= 1.0
60
+ if (cell.content.to_f - cell.content.to_f.floor).abs > 0.000001
61
+ tmp_type = :datetime
62
+ else
63
+ tmp_type = :date
64
+ end
65
+ else
66
+ end
67
+ end
68
+ excelx_type = [:numeric_or_formula,format.to_s]
69
+ excelx_value = cell.content
70
+ if tmp_type == :shared
71
+ vt = :string
72
+ str_v = @shared_table[cell.content.to_i]
73
+ excelx_type = :string
74
+ elsif tmp_type == :boolean
75
+ vt = :boolean
76
+ cell.content.to_i == 1 ? v = 'TRUE' : v = 'FALSE'
77
+ elsif tmp_type == :date
78
+ vt = :date
79
+ v = cell.content
80
+ elsif tmp_type == :time
81
+ vt = :time
82
+ v = cell.content
83
+ elsif tmp_type == :datetime
84
+ vt = :datetime
85
+ v = cell.content
86
+ elsif tmp_type == :formula
87
+ vt = :formula
88
+ v = cell.content.to_f #TODO: !!!!
89
+ # 2011-02-25 BEGIN
90
+ elsif tmp_type == :string
91
+ vt = :string
92
+ str_v = cell.content
93
+ excelx_type = :string
94
+ # 2011-02-25 END
95
+ else
96
+ vt = :float
97
+ v = cell.content
98
+ end
99
+ y, x = GenericSpreadsheet.split_coordinate(c['r'])
100
+ tr=nil #TODO: ???s
101
+ # set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v,excelx_type,excelx_value,s_attribute)
102
+ puts v
103
+ row_content << v
104
+ end
105
+ end
106
+ yield(row_content, row_index)
107
+ row_index += 1
108
+ end
109
+ sheet_found = true #TODO:
110
+ if !sheet_found
111
+ raise RangeError
112
+ end
113
+ @cells_read[sheet] = true
114
+
115
+ end
116
+
117
+ end
@@ -5,6 +5,10 @@ class CsvReader < SpreadsheetReader
5
5
  @engine = CsvExtended.new(@path) # Roo
6
6
  end
7
7
 
8
+ def foreach(sheet, &block)
9
+ @engine.foreach(sheet, &block)
10
+ end
11
+
8
12
  include RooModule
9
13
 
10
14
  end
@@ -5,6 +5,10 @@ class CsvtReader < SpreadsheetReader
5
5
  @engine = CsvtExtended.new(@path) # Roo
6
6
  end
7
7
 
8
+ def foreach(sheet, &block)
9
+ @engine.foreach(sheet, &block)
10
+ end
11
+
8
12
  include RooModule
9
13
 
10
14
  end
@@ -5,6 +5,10 @@ class CsvxReader < SpreadsheetReader
5
5
  @engine = CsvxExtended.new(@path) # Roo
6
6
  end
7
7
 
8
+ def foreach(sheet, &block)
9
+ @engine.foreach(sheet, &block)
10
+ end
11
+
8
12
  include RooModule
9
13
 
10
14
  end
@@ -5,6 +5,10 @@ class ExcelReader < SpreadsheetReader
5
5
  @engine = ExcelExtended.new(@path) # Roo
6
6
  end
7
7
 
8
+ def foreach(sheet, &block)
9
+ @engine.foreach(sheet, &block)
10
+ end
11
+
8
12
  include RooModule
9
13
 
10
14
  end
@@ -2,9 +2,13 @@ class ExcelxReader < SpreadsheetReader
2
2
 
3
3
  def initialize(file)
4
4
  super
5
- @engine = Excelx.new(file) # Roo
5
+ @engine = ExcelxExtended.new(file) # Roo
6
6
  end
7
7
 
8
+ def foreach(sheet, &block)
9
+ @engine.foreach(sheet, &block)
10
+ end
11
+
8
12
  include RooModule
9
13
 
10
14
  end
@@ -1,10 +1,10 @@
1
1
  class OpenofficeReader < SpreadsheetReader
2
-
2
+
3
3
  def initialize(file)
4
4
  super
5
- @engine = Openoffice.new(@path) # Roo
5
+ @engine = Roo::Openoffice.new(@path) # Roo
6
6
  end
7
-
7
+
8
8
  include RooModule
9
9
 
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleSpreadsheet
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -14,11 +14,11 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "simple-spreadsheet"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SimpleSpreadsheet::VERSION
17
-
17
+
18
18
  # specify any dependencies here; for example:
19
19
  gem.add_development_dependency "rspec", "~> 2.6.0"
20
20
  gem.add_development_dependency "rake", "~> 0.9.2.2"
21
- gem.add_runtime_dependency "roo", "1.10.1"
21
+ gem.add_runtime_dependency "roo", "1.11.2"
22
22
  gem.add_runtime_dependency "spreadsheet", "0.6.5.9"
23
23
  gem.add_runtime_dependency "rubyXL", "1.2.5"
24
24
  end
@@ -28,6 +28,13 @@ describe SimpleSpreadsheet do
28
28
  it "should correctly count column" do
29
29
  @workbook.last_column.should eq(2)
30
30
  end
31
+ it "should parse line by line" do
32
+ @workbook.foreach(@workbook.sheets.first) do |row, index|
33
+ row[0].should eq("String1")
34
+ row[1].should eq("1")
35
+ index.should eq(1)
36
+ end
37
+ end
31
38
  end
32
39
 
33
40
  end
@@ -28,6 +28,13 @@ describe SimpleSpreadsheet do
28
28
  it "should correctly count column" do
29
29
  @workbook.last_column.should eq(2)
30
30
  end
31
+ it "should parse line by line" do
32
+ @workbook.foreach(@workbook.sheets.first) do |row, index|
33
+ row[0].should eq("String1")
34
+ row[1].should eq("1")
35
+ index.should eq(1)
36
+ end
37
+ end
31
38
  end
32
39
 
33
40
  end
@@ -28,6 +28,13 @@ describe SimpleSpreadsheet do
28
28
  it "should correctly count column" do
29
29
  @workbook.last_column.should eq(2)
30
30
  end
31
+ it "should parse line by line" do
32
+ @workbook.foreach(@workbook.sheets.first) do |row, index|
33
+ row[0].should eq("String1")
34
+ row[1].should eq("1")
35
+ index.should eq(1)
36
+ end
37
+ end
31
38
  end
32
39
 
33
40
  end
@@ -42,6 +42,14 @@ describe SimpleSpreadsheet do
42
42
  it "should correctly count column" do
43
43
  @workbook.last_column.should eq(2)
44
44
  end
45
+ it "should parse line by line" do
46
+ @workbook.foreach(@workbook.sheets.first) do |row, index|
47
+ row[0].should eq("String1")
48
+ row[1].should eq(1.0)
49
+ index.should eq(1)
50
+ end
51
+ end
52
+
45
53
  end
46
54
 
47
55
  end
@@ -42,6 +42,13 @@ describe SimpleSpreadsheet do
42
42
  it "should correctly count column" do
43
43
  @workbook.last_column.should eq(2)
44
44
  end
45
+ # it "should parse line by line" do
46
+ # @workbook.foreach(@workbook.sheets.first) do |row, index|
47
+ # row[0].should eq("String1")
48
+ # row[1].should eq(1.0)
49
+ # index.should eq(1)
50
+ # end
51
+ # end
45
52
  end
46
53
 
47
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2013-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 1.10.1
53
+ version: 1.11.2
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.10.1
61
+ version: 1.11.2
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: spreadsheet
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
104
  - .rspec
105
+ - .travis.yml
105
106
  - Gemfile
106
107
  - Gemfile.lock
107
108
  - README.md
@@ -111,6 +112,7 @@ files:
111
112
  - lib/simple-spreadsheet/classes/csvt_extended.rb
112
113
  - lib/simple-spreadsheet/classes/csvx_extended.rb
113
114
  - lib/simple-spreadsheet/classes/excel_extended.rb
115
+ - lib/simple-spreadsheet/classes/excelx_extended.rb
114
116
  - lib/simple-spreadsheet/editors/csv_editor.rb
115
117
  - lib/simple-spreadsheet/editors/excel_editor.rb
116
118
  - lib/simple-spreadsheet/editors/excelx_editor.rb
@@ -190,3 +192,4 @@ test_files:
190
192
  - spec/simple-spreadsheet_xls_spec.rb
191
193
  - spec/simple-spreadsheet_xlsx_spec.rb
192
194
  - spec/spec_helper.rb
195
+ has_rdoc: