jruby-poi 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,4 +1,4 @@
1
- jruby-poi
1
+ [jruby-poi](http://github.com/sdeming/jruby-poi)
2
2
  =========
3
3
 
4
4
  This little gem provides an alternative interface to the Apache POI java library, for JRuby. For now the API is targeted at wrapping spreadsheets. We may expand this in the future.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
data/jruby-poi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jruby-poi}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Deming", "Jason Rogers"]
12
- s.date = %q{2010-08-30}
12
+ s.date = %q{2010-09-01}
13
13
  s.description = %q{A rubyesque library for manipulating spreadsheets and other document types for jruby, using Apache POI.}
14
14
  s.email = ["sdeming@makefile.com", "jacaetevha@gmail.com"]
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,10 @@ module POI
35
35
  @cell = cell
36
36
  end
37
37
 
38
+ def error_value
39
+ @error_value
40
+ end
41
+
38
42
  def value
39
43
  return nil if @cell.nil?
40
44
  value_of(cell_value_for_type(@cell.getCellType))
@@ -81,16 +85,19 @@ module POI
81
85
  end
82
86
 
83
87
  def cell_value_for_type(cell_type)
84
- case cell_type
85
- when CELL_TYPE_BLANK: nil
86
- when CELL_TYPE_BOOLEAN: CELL_VALUE.valueOf(@cell.getBooleanCellValue)
87
- when CELL_TYPE_FORMULA
88
- formula_evaluator = Java::org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.new @cell.sheet.workbook
89
- formula_evaluator.evaluate @cell
90
- when CELL_TYPE_STRING: CELL_VALUE.new(@cell.getStringCellValue)
91
- when CELL_TYPE_ERROR, CELL_TYPE_NUMERIC: CELL_VALUE.new(@cell.getNumericCellValue)
92
- else
93
- raise "unhandled cell type[#{@cell.getCellType}]"
88
+ begin
89
+ case cell_type
90
+ when CELL_TYPE_BLANK: nil
91
+ when CELL_TYPE_BOOLEAN: CELL_VALUE.valueOf(@cell.getBooleanCellValue)
92
+ when CELL_TYPE_FORMULA: cell_value_for_type(@cell.getCachedFormulaResultType)
93
+ when CELL_TYPE_STRING: CELL_VALUE.new(@cell.getStringCellValue)
94
+ when CELL_TYPE_ERROR, CELL_TYPE_NUMERIC: CELL_VALUE.new(@cell.getNumericCellValue)
95
+ else
96
+ raise "unhandled cell type[#{@cell.getCellType}]"
97
+ end
98
+ rescue
99
+ @error_value = $!
100
+ nil
94
101
  end
95
102
  end
96
103
  end
@@ -150,25 +150,41 @@ describe POI::Cells do
150
150
  sheet = book.worksheets["bools & errors"]
151
151
  rows = sheet.rows
152
152
 
153
- rows[6][0].value.should == '~CIRCULAR~REF~'
154
- rows[7][0].value.should == '#DIV/0!'
155
- rows[8][0].value.should == '#N/A'
156
- rows[9][0].value.should == '#NAME?'
157
- rows[10][0].value.should == '#NULL!'
158
- rows[11][0].value.should == '#NUM!'
159
- rows[12][0].value.should == '#REF!'
160
- rows[13][0].value.should == '#VALUE!'
161
- lambda{ rows[14][0].value }.should raise_error(Java::java.lang.RuntimeException)
153
+ rows[6][0].value.should == 0.0 #'~CIRCULAR~REF~'
154
+ rows[6][0].error_value.should be_nil
155
+
156
+ rows[7][0].value.should be_nil #'#DIV/0!'
157
+ rows[7][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
158
+
159
+ rows[8][0].value.should be_nil #'#N/A'
160
+ rows[8][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
161
+
162
+ rows[9][0].value.should be_nil #'#NAME?'
163
+ rows[9][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
164
+
165
+ rows[10][0].value.should be_nil #'#NULL!'
166
+ rows[10][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
167
+
168
+ rows[11][0].value.should be_nil #'#NUM!'
169
+ rows[11][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
170
+
171
+ rows[12][0].value.should be_nil #'#REF!'
172
+ rows[12][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
173
+
174
+ rows[13][0].value.should be_nil #'#VALUE!'
175
+ rows[13][0].error_value.should == 'java.lang.NumberFormatException: For input string: "#N/A"'
176
+
177
+ lambda{ rows[14][0].value }.should_not raise_error(Java::java.lang.RuntimeException)
162
178
 
163
- rows[6][0].to_s.should == '~CIRCULAR~REF~'
164
- rows[7][0].to_s.should == '#DIV/0!'
165
- rows[8][0].to_s.should == '#N/A'
166
- rows[9][0].to_s.should == '#NAME?'
167
- rows[10][0].to_s.should == '#NULL!'
168
- rows[11][0].to_s.should == '#NUM!'
169
- rows[12][0].to_s.should == '#REF!'
170
- rows[13][0].to_s.should == '#VALUE!'
171
- lambda{ rows[14][0].to_s }.should raise_error(Java::java.lang.RuntimeException)
179
+ rows[6][0].to_s.should == '0.0' #'~CIRCULAR~REF~'
180
+ rows[7][0].to_s.should == '' #'#DIV/0!'
181
+ rows[8][0].to_s.should == '' #'#N/A'
182
+ rows[9][0].to_s.should == '' #'#NAME?'
183
+ rows[10][0].to_s.should == '' #'#NULL!'
184
+ rows[11][0].to_s.should == '' #'#NUM!'
185
+ rows[12][0].to_s.should == '' #'#REF!'
186
+ rows[13][0].to_s.should == '' #'#VALUE!'
187
+ rows[14][0].to_s.should == ''
172
188
  end
173
189
 
174
190
  it "should provide booleans for boolean cells" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Deming
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-30 00:00:00 -04:00
18
+ date: 2010-09-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21