jruby-poi 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.markdown +1 -0
- data/VERSION +1 -1
- data/jruby-poi.gemspec +67 -0
- data/lib/poi/workbook/cell.rb +55 -2
- data/lib/poi/workbook/row.rb +4 -0
- data/lib/poi/workbook/workbook.rb +19 -8
- data/spec_debug.sh +21 -0
- data/specs/data/various_samples.xlsx +0 -0
- data/specs/spec_helper.rb +1 -0
- data/specs/support/matchers/cell_matcher.rb +17 -0
- data/specs/workbook_spec.rb +164 -29
- metadata +7 -4
- data/specs/data/simple_with_picture.xlsx +0 -0
data/.gitignore
CHANGED
data/README.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/jruby-poi.gemspec
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jruby-poi}
|
8
|
+
s.version = "0.4.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Scott Deming"]
|
12
|
+
s.date = %q{2010-08-27}
|
13
|
+
s.description = %q{A rubyesque library for manipulating spreadsheets and other document types for jruby, using Apache POI.}
|
14
|
+
s.email = %q{sdeming@makefile.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"NOTICE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"jruby-poi.gemspec",
|
27
|
+
"lib/ooxml-lib/dom4j-1.6.1.jar",
|
28
|
+
"lib/ooxml-lib/geronimo-stax-api_1.0_spec-1.0.jar",
|
29
|
+
"lib/ooxml-lib/xmlbeans-2.3.0.jar",
|
30
|
+
"lib/poi-3.6-20091214.jar",
|
31
|
+
"lib/poi-contrib-3.6-20091214.jar",
|
32
|
+
"lib/poi-examples-3.6-20091214.jar",
|
33
|
+
"lib/poi-ooxml-3.6-20091214.jar",
|
34
|
+
"lib/poi-ooxml-schemas-3.6-20091214.jar",
|
35
|
+
"lib/poi-scratchpad-3.6-20091214.jar",
|
36
|
+
"lib/poi.rb",
|
37
|
+
"lib/poi/workbook.rb",
|
38
|
+
"lib/poi/workbook/cell.rb",
|
39
|
+
"lib/poi/workbook/row.rb",
|
40
|
+
"lib/poi/workbook/workbook.rb",
|
41
|
+
"lib/poi/workbook/worksheet.rb",
|
42
|
+
"spec_debug.sh",
|
43
|
+
"specs/data/simple_with_picture.ods",
|
44
|
+
"specs/data/simple_with_picture.xls",
|
45
|
+
"specs/data/various_samples.xlsx",
|
46
|
+
"specs/io_spec.rb",
|
47
|
+
"specs/spec_helper.rb",
|
48
|
+
"specs/support/matchers/cell_matcher.rb",
|
49
|
+
"specs/workbook_spec.rb"
|
50
|
+
]
|
51
|
+
s.homepage = %q{http://github.com/sdeming/jruby-poi}
|
52
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubygems_version = %q{1.3.6}
|
55
|
+
s.summary = %q{Apache POI class library for jruby}
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
+
s.specification_version = 3
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
+
else
|
63
|
+
end
|
64
|
+
else
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/poi/workbook/cell.rb
CHANGED
@@ -22,21 +22,74 @@ module POI
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class Cell
|
25
|
+
CELL = Java::org.apache.poi.ss.usermodel.Cell
|
26
|
+
CELL_VALUE = Java::org.apache.poi.ss.usermodel.CellValue
|
27
|
+
CELL_TYPE_BLANK = CELL::CELL_TYPE_BLANK
|
28
|
+
CELL_TYPE_BOOLEAN = CELL::CELL_TYPE_BOOLEAN
|
29
|
+
CELL_TYPE_ERROR = CELL::CELL_TYPE_ERROR
|
30
|
+
CELL_TYPE_FORMULA = CELL::CELL_TYPE_FORMULA
|
31
|
+
CELL_TYPE_NUMERIC = CELL::CELL_TYPE_NUMERIC
|
32
|
+
CELL_TYPE_STRING = CELL::CELL_TYPE_STRING
|
33
|
+
|
25
34
|
def initialize(cell)
|
26
35
|
@cell = cell
|
27
36
|
end
|
37
|
+
|
38
|
+
def value
|
39
|
+
value_of(cell_value_for_type(@cell.getCellType))
|
40
|
+
end
|
41
|
+
|
42
|
+
def comment
|
43
|
+
@cell.getCellComment
|
44
|
+
end
|
28
45
|
|
29
46
|
def index
|
30
47
|
@cell.getColumnIndex
|
31
48
|
end
|
32
49
|
|
33
|
-
def to_s
|
34
|
-
@cell.
|
50
|
+
def to_s(evaluate_formulas=true)
|
51
|
+
if @cell.getCellType == CELL_TYPE_FORMULA
|
52
|
+
evaluate_formulas ? value.to_s : @cell.getCellFormula
|
53
|
+
else
|
54
|
+
value.to_s
|
55
|
+
end
|
35
56
|
end
|
36
57
|
|
37
58
|
def poi_cell
|
38
59
|
@cell
|
39
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def value_of(cell_value)
|
64
|
+
case cell_value.getCellType
|
65
|
+
when CELL_TYPE_BLANK: nil
|
66
|
+
when CELL_TYPE_BOOLEAN: cell_value.getBooleanValue
|
67
|
+
when CELL_TYPE_ERROR: Java::org.apache.poi.hssf.record.formula.eval.ErrorEval.getText(cell_value.getErrorValue)
|
68
|
+
when CELL_TYPE_NUMERIC
|
69
|
+
if Java::org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted @cell
|
70
|
+
Date.parse(Java::org.apache.poi.ss.usermodel.DateUtil.getJavaDate(cell_value.getNumberValue).to_s)
|
71
|
+
else
|
72
|
+
cell_value.getNumberValue
|
73
|
+
end
|
74
|
+
when CELL_TYPE_STRING: cell_value.getStringValue
|
75
|
+
else
|
76
|
+
raise "unhandled cell type[#{@cell.getCellType}]"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def cell_value_for_type(cell_type)
|
81
|
+
case cell_type
|
82
|
+
when CELL_TYPE_BLANK: nil
|
83
|
+
when CELL_TYPE_BOOLEAN: CELL_VALUE.valueOf(@cell.getBooleanCellValue)
|
84
|
+
when CELL_TYPE_FORMULA
|
85
|
+
formula_evaluator = Java::org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.new @cell.sheet.workbook
|
86
|
+
formula_evaluator.evaluate @cell
|
87
|
+
when CELL_TYPE_STRING: CELL_VALUE.new(@cell.getStringCellValue)
|
88
|
+
when CELL_TYPE_ERROR, CELL_TYPE_NUMERIC: CELL_VALUE.new(@cell.getNumericCellValue)
|
89
|
+
else
|
90
|
+
raise "unhandled cell type[#{@cell.getCellType}]"
|
91
|
+
end
|
92
|
+
end
|
40
93
|
end
|
41
94
|
end
|
42
95
|
|
data/lib/poi/workbook/row.rb
CHANGED
@@ -1,24 +1,35 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'stringio'
|
3
|
+
|
1
4
|
module POI
|
2
5
|
class Workbook
|
3
|
-
def self.open(
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
def self.open(filename_or_stream)
|
7
|
+
name, stream = if filename_or_stream.kind_of?(java.io.InputStream)
|
8
|
+
[File.join(Dir.tmpdir, "spreadsheet.xlsx"), filename_or_stream]
|
9
|
+
elsif filename_or_stream.kind_of?(IO) || StringIO === filename_or_stream || filename_or_stream.respond_to?(:read)
|
10
|
+
# NOTE: the String.unpack here can be very inefficient
|
11
|
+
[File.join(Dir.tmpdir, "spreadsheet.xlsx"), java.io.ByteArrayInputStream.new(filename_or_stream.read.unpack('c*').to_java(:byte))]
|
12
|
+
else
|
13
|
+
raise Exception, "FileNotFound" unless File.exists?( filename_or_stream )
|
14
|
+
[filename_or_stream, java.io.FileInputStream.new(filename_or_stream)]
|
15
|
+
end
|
16
|
+
instance = self.new(name, stream)
|
7
17
|
if block_given?
|
8
18
|
result = yield instance
|
9
19
|
return result
|
10
20
|
end
|
11
|
-
|
12
21
|
instance
|
13
22
|
end
|
23
|
+
|
24
|
+
attr_reader :filename
|
14
25
|
|
15
|
-
def initialize(filename)
|
26
|
+
def initialize(filename, io_stream)
|
16
27
|
@filename = filename
|
17
|
-
@workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create(
|
28
|
+
@workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create(io_stream)
|
18
29
|
end
|
19
30
|
|
20
31
|
def save
|
21
|
-
|
32
|
+
save_as(@filename)
|
22
33
|
end
|
23
34
|
|
24
35
|
def save_as(filename)
|
data/spec_debug.sh
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#set -x
|
3
|
+
RUBY_DIR=$(dirname $(which ruby))/..
|
4
|
+
RUBYGEMS_DIR=${RUBY_DIR}/lib/ruby/gems/1.8/gems
|
5
|
+
|
6
|
+
GEM_COLUMNIZE=$(ls -1d $RUBYGEMS_DIR/columnize*/lib | head -1 | /usr/bin/ruby -e 'print File.expand_path($stdin.read)')
|
7
|
+
GEM_RUBY_DEBUG_BASE=$(ls -1d $RUBYGEMS_DIR/ruby-debug-base-*/lib | head -1 | /usr/bin/ruby -e 'print File.expand_path($stdin.read)')
|
8
|
+
GEM_RUBY_DEBUG_CLI=$(ls -1d $RUBYGEMS_DIR/ruby-debug-*/cli | head -1 | /usr/bin/ruby -e 'print File.expand_path($stdin.read)')
|
9
|
+
GEM_SOURCES=$(ls -1d $RUBYGEMS_DIR/sources-*/lib | head -1 | /usr/bin/ruby -e 'print File.expand_path($stdin.read)')
|
10
|
+
|
11
|
+
runner="ruby --client \
|
12
|
+
-I${GEM_COLUMNIZE} \
|
13
|
+
-I${GEM_RUBY_DEBUG_BASE} \
|
14
|
+
-I${GEM_RUBY_DEBUG_CLI} \
|
15
|
+
-I${GEM_SOURCES} \
|
16
|
+
-rubygems -S"
|
17
|
+
|
18
|
+
cmd="spec -c --debugger $*"
|
19
|
+
#cmd="irb"
|
20
|
+
|
21
|
+
$runner $cmd
|
Binary file
|
data/specs/spec_helper.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
Spec::Matchers.define :equal_at_cell do |expected, row, col|
|
2
|
+
match do |actual|
|
3
|
+
actual == expected
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message_for_should do |actual|
|
7
|
+
"expected #{actual} to equal #{expected} (row:#{row}, cell:#{col})"
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should_not do |actual|
|
11
|
+
"expected #{actual} not to equal #{expected} (row:#{row}, cell:#{col})"
|
12
|
+
end
|
13
|
+
|
14
|
+
description do
|
15
|
+
"to equal #{expected}"
|
16
|
+
end
|
17
|
+
end
|
data/specs/workbook_spec.rb
CHANGED
@@ -1,35 +1,52 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'date'
|
3
|
+
require 'stringio'
|
2
4
|
|
3
5
|
describe POI::Workbook do
|
4
6
|
it "should open a workbook and allow access to its worksheets" do
|
5
|
-
name = TestDataFile.expand_path("
|
7
|
+
name = TestDataFile.expand_path("various_samples.xlsx")
|
6
8
|
book = POI::Workbook.open(name)
|
9
|
+
book.worksheets.size.should == 4
|
10
|
+
book.filename.should == name
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to create a Workbook from an IO object" do
|
14
|
+
content = StringIO.new(open(TestDataFile.expand_path("various_samples.xlsx"), 'rb'){|f| f.read})
|
15
|
+
book = POI::Workbook.open(content)
|
16
|
+
book.worksheets.size.should == 4
|
17
|
+
book.filename.should =~ /spreadsheet.xlsx$/
|
18
|
+
end
|
7
19
|
|
8
|
-
|
20
|
+
it "should be able to create a Workbook from a Java input stream" do
|
21
|
+
content = java.io.FileInputStream.new(TestDataFile.expand_path("various_samples.xlsx"))
|
22
|
+
book = POI::Workbook.open(content)
|
23
|
+
book.worksheets.size.should == 4
|
24
|
+
book.filename.should =~ /spreadsheet.xlsx$/
|
9
25
|
end
|
10
26
|
end
|
11
27
|
|
12
28
|
describe POI::Worksheets do
|
13
29
|
it "should allow indexing worksheets by ordinal" do
|
14
|
-
name = TestDataFile.expand_path("
|
30
|
+
name = TestDataFile.expand_path("various_samples.xlsx")
|
15
31
|
book = POI::Workbook.open(name)
|
16
32
|
|
17
|
-
book.worksheets[0].name.should == "
|
18
|
-
book.worksheets[1].name.should == "
|
19
|
-
book.worksheets[2].name.should == "
|
33
|
+
book.worksheets[0].name.should == "text & pic"
|
34
|
+
book.worksheets[1].name.should == "numbers"
|
35
|
+
book.worksheets[2].name.should == "dates"
|
36
|
+
book.worksheets[3].name.should == "bools & errors"
|
20
37
|
end
|
21
38
|
|
22
39
|
it "should allow indexing worksheets by name" do
|
23
|
-
name = TestDataFile.expand_path("
|
40
|
+
name = TestDataFile.expand_path("various_samples.xlsx")
|
24
41
|
book = POI::Workbook.open(name)
|
25
42
|
|
26
|
-
book.worksheets["
|
27
|
-
book.worksheets["
|
28
|
-
book.worksheets["
|
43
|
+
book.worksheets["text & pic"].name.should == "text & pic"
|
44
|
+
book.worksheets["numbers"].name.should == "numbers"
|
45
|
+
book.worksheets["dates"].name.should == "dates"
|
29
46
|
end
|
30
47
|
|
31
48
|
it "should be enumerable" do
|
32
|
-
name = TestDataFile.expand_path("
|
49
|
+
name = TestDataFile.expand_path("various_samples.xlsx")
|
33
50
|
book = POI::Workbook.open(name)
|
34
51
|
book.worksheets.should be_kind_of Enumerable
|
35
52
|
|
@@ -37,32 +54,43 @@ describe POI::Worksheets do
|
|
37
54
|
sheet.should be_kind_of POI::Worksheet
|
38
55
|
end
|
39
56
|
|
40
|
-
book.worksheets.size.should ==
|
41
|
-
book.worksheets.collect.size.should ==
|
57
|
+
book.worksheets.size.should == 4
|
58
|
+
book.worksheets.collect.size.should == 4
|
42
59
|
end
|
43
60
|
end
|
44
61
|
|
45
62
|
describe POI::Rows do
|
46
63
|
it "should be enumerable" do
|
47
|
-
name = TestDataFile.expand_path("
|
64
|
+
name = TestDataFile.expand_path("various_samples.xlsx")
|
48
65
|
book = POI::Workbook.open(name)
|
49
|
-
sheet = book.worksheets["
|
66
|
+
sheet = book.worksheets["text & pic"]
|
50
67
|
sheet.rows.should be_kind_of Enumerable
|
51
68
|
|
52
69
|
sheet.rows.each do |row|
|
53
70
|
row.should be_kind_of POI::Row
|
54
71
|
end
|
55
72
|
|
56
|
-
sheet.rows.size.should ==
|
57
|
-
sheet.rows.collect.size.should ==
|
73
|
+
sheet.rows.size.should == 7
|
74
|
+
sheet.rows.collect.size.should == 7
|
58
75
|
end
|
59
76
|
end
|
60
77
|
|
61
78
|
describe POI::Cells do
|
79
|
+
before :each do
|
80
|
+
@name = TestDataFile.expand_path("various_samples.xlsx")
|
81
|
+
@book = POI::Workbook.open(@name)
|
82
|
+
end
|
83
|
+
|
84
|
+
def book
|
85
|
+
@book
|
86
|
+
end
|
87
|
+
|
88
|
+
def name
|
89
|
+
@name
|
90
|
+
end
|
91
|
+
|
62
92
|
it "should be enumerable" do
|
63
|
-
|
64
|
-
book = POI::Workbook.open(name)
|
65
|
-
sheet = book.worksheets["Sheet1"]
|
93
|
+
sheet = book.worksheets["text & pic"]
|
66
94
|
rows = sheet.rows
|
67
95
|
cells = rows[0].cells
|
68
96
|
|
@@ -71,18 +99,125 @@ describe POI::Cells do
|
|
71
99
|
cells.collect.size.should == 1
|
72
100
|
end
|
73
101
|
|
102
|
+
it "should provide dates for date cells" do
|
103
|
+
sheet = book.worksheets["dates"]
|
104
|
+
rows = sheet.rows
|
105
|
+
|
106
|
+
dates_by_column = [
|
107
|
+
(Date.parse('2010-02-28')..Date.parse('2010-03-14')),
|
108
|
+
(Date.parse('2010-03-14')..Date.parse('2010-03-28')),
|
109
|
+
(Date.parse('2010-03-28')..Date.parse('2010-04-11'))]
|
110
|
+
(0..2).each do |col|
|
111
|
+
dates_by_column[col].each_with_index do |date, index|
|
112
|
+
row = index + 1
|
113
|
+
rows[row][col].value.should equal_at_cell(date, row, col)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should provide numbers for numeric cells" do
|
119
|
+
sheet = book.worksheets["numbers"]
|
120
|
+
rows = sheet.rows
|
121
|
+
|
122
|
+
(1..15).each do |number|
|
123
|
+
row = number
|
124
|
+
rows[row][0].value.should equal_at_cell(number, row, 0)
|
125
|
+
rows[row][1].value.should equal_at_cell(number ** 2, row, 1)
|
126
|
+
rows[row][2].value.should equal_at_cell(number ** 3, row, 2)
|
127
|
+
rows[row][3].value.should equal_at_cell(Math.sqrt(number), row, 3)
|
128
|
+
end
|
129
|
+
|
130
|
+
rows[9][0].to_s.should == '9.0'
|
131
|
+
rows[9][1].to_s.should == '81.0'
|
132
|
+
rows[9][2].to_s.should == '729.0'
|
133
|
+
rows[9][3].to_s.should == '3.0'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should provide error text for error cells" do
|
137
|
+
sheet = book.worksheets["bools & errors"]
|
138
|
+
rows = sheet.rows
|
139
|
+
|
140
|
+
rows[6][0].value.should == '~CIRCULAR~REF~'
|
141
|
+
rows[7][0].value.should == '#DIV/0!'
|
142
|
+
rows[8][0].value.should == '#N/A'
|
143
|
+
rows[9][0].value.should == '#NAME?'
|
144
|
+
rows[10][0].value.should == '#NULL!'
|
145
|
+
rows[11][0].value.should == '#NUM!'
|
146
|
+
rows[12][0].value.should == '#REF!'
|
147
|
+
rows[13][0].value.should == '#VALUE!'
|
148
|
+
lambda{ rows[14][0].value }.should raise_error(Java::java.lang.RuntimeException)
|
149
|
+
|
150
|
+
rows[6][0].to_s.should == '~CIRCULAR~REF~'
|
151
|
+
rows[7][0].to_s.should == '#DIV/0!'
|
152
|
+
rows[8][0].to_s.should == '#N/A'
|
153
|
+
rows[9][0].to_s.should == '#NAME?'
|
154
|
+
rows[10][0].to_s.should == '#NULL!'
|
155
|
+
rows[11][0].to_s.should == '#NUM!'
|
156
|
+
rows[12][0].to_s.should == '#REF!'
|
157
|
+
rows[13][0].to_s.should == '#VALUE!'
|
158
|
+
lambda{ rows[14][0].to_s }.should raise_error(Java::java.lang.RuntimeException)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should provide booleans for boolean cells" do
|
162
|
+
sheet = book.worksheets["bools & errors"]
|
163
|
+
rows = sheet.rows
|
164
|
+
rows[1][0].value.should == false
|
165
|
+
rows[1][0].to_s.should == 'false'
|
166
|
+
|
167
|
+
rows[1][1].value.should == false
|
168
|
+
rows[1][1].to_s.should == 'false'
|
169
|
+
|
170
|
+
rows[2][0].value.should == true
|
171
|
+
rows[2][0].to_s.should == 'true'
|
172
|
+
|
173
|
+
rows[2][1].value.should == true
|
174
|
+
rows[2][1].to_s.should == 'true'
|
175
|
+
end
|
176
|
+
|
74
177
|
it "should provide the cell value as a string" do
|
75
|
-
|
76
|
-
|
77
|
-
|
178
|
+
sheet = book.worksheets["text & pic"]
|
179
|
+
rows = sheet.rows
|
180
|
+
|
181
|
+
rows[0][0].value.should == "This"
|
182
|
+
rows[1][0].value.should == "is"
|
183
|
+
rows[2][0].value.should == "an"
|
184
|
+
rows[3][0].value.should == "Excel"
|
185
|
+
rows[4][0].value.should == "XLSX"
|
186
|
+
rows[5][0].value.should == "workbook"
|
187
|
+
rows[9][0].value.should == 'This is an Excel XLSX workbook.'
|
188
|
+
|
189
|
+
|
190
|
+
rows[0][0].to_s.should == "This"
|
191
|
+
rows[1][0].to_s.should == "is"
|
192
|
+
rows[2][0].to_s.should == "an"
|
193
|
+
rows[3][0].to_s.should == "Excel"
|
194
|
+
rows[4][0].to_s.should == "XLSX"
|
195
|
+
rows[5][0].to_s.should == "workbook"
|
196
|
+
rows[9][0].to_s.should == 'This is an Excel XLSX workbook.'
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should provide formulas instead of string-ified values" do
|
200
|
+
sheet = book.worksheets["numbers"]
|
78
201
|
rows = sheet.rows
|
79
202
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
203
|
+
(1..15).each do |number|
|
204
|
+
row = number
|
205
|
+
rows[row][0].to_s(false).should == "#{number}.0"
|
206
|
+
rows[row][1].to_s(false).should == "A#{row + 1}*A#{row + 1}"
|
207
|
+
rows[row][2].to_s(false).should == "B#{row + 1}*A#{row + 1}"
|
208
|
+
rows[row][3].to_s(false).should == "SQRT(A#{row + 1})"
|
209
|
+
end
|
210
|
+
|
211
|
+
sheet = book.worksheets["bools & errors"]
|
212
|
+
rows = sheet.rows
|
213
|
+
rows[1][0].to_s(false).should == '1=2'
|
214
|
+
rows[1][1].to_s(false).should == 'FALSE'
|
215
|
+
rows[2][0].to_s(false).should == '1=1'
|
216
|
+
rows[2][1].to_s(false).should == 'TRUE'
|
217
|
+
rows[14][0].to_s(false).should == 'foobar(1)'
|
218
|
+
|
219
|
+
sheet = book.worksheets["text & pic"]
|
220
|
+
sheet.rows[9][0].to_s(false).should == 'CONCATENATE(A1," ", A2," ", A3," ", A4," ", A5," ", A6,".")'
|
86
221
|
end
|
87
222
|
end
|
88
223
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 4
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott Deming
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-08-27 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- README.markdown
|
35
35
|
- Rakefile
|
36
36
|
- VERSION
|
37
|
+
- jruby-poi.gemspec
|
37
38
|
- lib/ooxml-lib/dom4j-1.6.1.jar
|
38
39
|
- lib/ooxml-lib/geronimo-stax-api_1.0_spec-1.0.jar
|
39
40
|
- lib/ooxml-lib/xmlbeans-2.3.0.jar
|
@@ -49,11 +50,13 @@ files:
|
|
49
50
|
- lib/poi/workbook/row.rb
|
50
51
|
- lib/poi/workbook/workbook.rb
|
51
52
|
- lib/poi/workbook/worksheet.rb
|
53
|
+
- spec_debug.sh
|
52
54
|
- specs/data/simple_with_picture.ods
|
53
55
|
- specs/data/simple_with_picture.xls
|
54
|
-
- specs/data/
|
56
|
+
- specs/data/various_samples.xlsx
|
55
57
|
- specs/io_spec.rb
|
56
58
|
- specs/spec_helper.rb
|
59
|
+
- specs/support/matchers/cell_matcher.rb
|
57
60
|
- specs/workbook_spec.rb
|
58
61
|
has_rdoc: true
|
59
62
|
homepage: http://github.com/sdeming/jruby-poi
|
Binary file
|