jruby_excelcom 0.0.2-java → 0.0.4-java
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.
- checksums.yaml +4 -4
- data/{jruby_excelcom.gemspec → .//jruby_excelcom.gemspec} +4 -2
- data/lib/jruby_excelcom/excel_connection.rb +16 -0
- data/lib/jruby_excelcom/worksheet.rb +21 -1
- data/lib/jruby_excelcom.rb +6 -6
- data/test/test_helper.rb +8 -0
- data/test/unit/excel_connection_spec.rb +14 -4
- data/test/unit/workbook_spec.rb +3 -3
- data/test/unit/worksheet_spec.rb +11 -3
- metadata +39 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e86a5a545a59b53142a958df3ce881ca84654203
|
4
|
+
data.tar.gz: 6609ca73a5186d9d5121a97888932503f1cda522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 180415ce38b272e409cf41c012120d91b771556b5ed6d5ce226349470a77d2be6f55d5728e199e5b1e710a9ffa1c58dcba2cd56b53199079113b383e6467c4af
|
7
|
+
data.tar.gz: 21f7fdd9b74d7e2c5629a398fcb578d352c7c7e8b5c6f2ddcf676544d903af49dade61e6f7290195966589ca885203471cff7f1d37d8c46ff30eb948cc8f4141
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'jruby_excelcom'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.4'
|
4
4
|
s.date = Time.now.strftime('%Y-%m-%d')
|
5
5
|
s.platform = 'java'
|
6
6
|
s.summary = "Excel spreadsheet modification using COM"
|
@@ -8,6 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["lprc"]
|
9
9
|
s.files = Dir.glob("{doc,lib,test}/**/*") + ['LICENSE', __FILE__]
|
10
10
|
s.require_paths = ['lib']
|
11
|
-
s.homepage = '
|
11
|
+
s.homepage = 'https://github.com/lprc/jruby_excelcom'
|
12
12
|
s.license = 'Apache-2.0'
|
13
|
+
s.add_development_dependency 'minitest', '~> 4.7'
|
14
|
+
s.add_development_dependency 'minitest-reporters', '~> 0.14'
|
13
15
|
end
|
@@ -78,4 +78,20 @@ class ExcelConnection
|
|
78
78
|
alias :openWorkbook :workbook
|
79
79
|
alias :open_workbook :workbook
|
80
80
|
|
81
|
+
# creates a new workbook. If block is given, workbook will be saved and closed at end
|
82
|
+
def new_workbook(file)
|
83
|
+
if file.is_a? String
|
84
|
+
wb = Workbook.new(@con.newWorkbook(java.io.File.new(file)))
|
85
|
+
else
|
86
|
+
wb = Workbook.new(@con.newWorkbook(java.io.File.new(file.path)))
|
87
|
+
end
|
88
|
+
if block_given?
|
89
|
+
yield(wb)
|
90
|
+
wb.close true
|
91
|
+
else
|
92
|
+
wb
|
93
|
+
end
|
94
|
+
end
|
95
|
+
alias :add_workbook :new_workbook
|
96
|
+
|
81
97
|
end
|
@@ -26,7 +26,7 @@ class Worksheet
|
|
26
26
|
# returns the content in range as a matrix, a vector or a single value, depending on +range+'s dimensions
|
27
27
|
# +range+:: range with content to get, default value is _UsedRange_
|
28
28
|
def content(range = 'UsedRange')
|
29
|
-
c = @ws.getContent(range).to_a.
|
29
|
+
c = @ws.getContent(range).to_a.map!{ |row| row.to_a }
|
30
30
|
columns = c.size
|
31
31
|
rows = columns > 0 ? c[0].size : 0
|
32
32
|
if columns == 1 and rows == 1 # range is one cell
|
@@ -131,6 +131,26 @@ class Worksheet
|
|
131
131
|
end
|
132
132
|
alias :getBorderColor :border_color
|
133
133
|
|
134
|
+
# sets comment of cells in range
|
135
|
+
# +range+:: range
|
136
|
+
# +comment+:: comment text
|
137
|
+
def set_comment(range, comment)
|
138
|
+
@ws.setComment(range, comment)
|
139
|
+
end
|
140
|
+
alias :setComment :set_comment
|
134
141
|
|
142
|
+
# sets comment of cells in range
|
143
|
+
# +hash+:: must contain +:range+ and +:comment+
|
144
|
+
def comment=(hash)
|
145
|
+
raise ArgumentError, 'cannot set border color, argument is not a hash' unless hash.is_a? Hash
|
146
|
+
raise ArgumentError, 'cannot set border color, hash does not contain :range or :comment key' if hash[:range].nil? or hash[:comment].nil?
|
147
|
+
set_comment hash[:range], hash[:comment]
|
148
|
+
end
|
149
|
+
|
150
|
+
# gets the comment of cells in range. Throws a +NullpointerException+ if range contains multiple comments
|
151
|
+
def comment(range)
|
152
|
+
@ws.getComment(range)
|
153
|
+
end
|
154
|
+
alias :getComment :comment
|
135
155
|
|
136
156
|
end
|
data/lib/jruby_excelcom.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'java'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
require 'jars/jna-4.4.0.jar'
|
5
|
+
require 'jars/jna-platform-4.4.0.jar'
|
6
|
+
require 'jars/excelcom-0.0.6.jar'
|
7
|
+
require 'jruby_excelcom/excel_connection'
|
8
|
+
require 'jruby_excelcom/workbook'
|
9
|
+
require 'jruby_excelcom/worksheet'
|
10
10
|
|
11
11
|
java_import 'excelcom.api.ExcelException'
|
12
12
|
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
$:.unshift "#{File.expand_path(__FILE__)}/../lib"
|
4
|
+
|
5
|
+
# define public_send for Object for minitest-reporters (actually first defined in Ruby 1.9)
|
6
|
+
class Object
|
7
|
+
alias :public_send :send unless method_defined?(:public_send)
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rubygems'
|
3
11
|
require 'minitest/reporters'
|
4
12
|
MiniTest::Reporters.use!
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
|
-
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'jruby_excelcom'
|
5
6
|
|
6
7
|
describe 'ExcelConnection' do
|
7
8
|
|
@@ -10,9 +11,9 @@ describe 'ExcelConnection' do
|
|
10
11
|
e.display_alerts = false
|
11
12
|
e
|
12
13
|
end
|
13
|
-
$wb ||= $con.workbook("#{File.dirname(File.
|
14
|
+
$wb ||= $con.workbook("#{File.dirname(File.expand_path(__FILE__))}/../resources/test.xlsx")
|
14
15
|
|
15
|
-
Minitest.
|
16
|
+
Minitest::Unit.after_tests {
|
16
17
|
$wb.close unless $wb.nil?; $wb = nil
|
17
18
|
$con.quit unless $con.nil?; $con = nil
|
18
19
|
}
|
@@ -30,9 +31,18 @@ describe 'ExcelConnection' do
|
|
30
31
|
|
31
32
|
it '#workbook' do
|
32
33
|
$wb.wont_be_nil
|
33
|
-
$con.workbook("#{File.dirname(File.
|
34
|
+
$con.workbook("#{File.dirname(File.expand_path(__FILE__))}/../resources/test2.xlsx") { |wb|
|
34
35
|
wb.name.is_a? String
|
35
36
|
}
|
36
37
|
end
|
37
38
|
|
39
|
+
it '#new_workbook' do
|
40
|
+
path = "#{Dir.tmpdir}/newwb.xlsx"
|
41
|
+
$con.new_workbook(path) { |wb|
|
42
|
+
wb.name.must_equal "newwb.xlsx"
|
43
|
+
}
|
44
|
+
File.exists?(path).must_equal true
|
45
|
+
File.delete path
|
46
|
+
end
|
47
|
+
|
38
48
|
end
|
data/test/unit/workbook_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
|
-
|
4
|
+
require 'jruby_excelcom'
|
5
5
|
|
6
6
|
describe 'Workbook' do
|
7
7
|
|
8
|
-
Minitest.
|
8
|
+
Minitest::Unit.after_tests {
|
9
9
|
$wb.close unless $wb.nil?; $wb = nil
|
10
10
|
$con.quit unless $con.nil?; $con = nil
|
11
11
|
File.delete($temp_file_path) if not $temp_file_path.nil? and File.exists?($temp_file_path)
|
@@ -16,7 +16,7 @@ describe 'Workbook' do
|
|
16
16
|
e.display_alerts = false
|
17
17
|
e
|
18
18
|
end
|
19
|
-
$wb ||= $con.workbook("#{File.dirname(File.
|
19
|
+
$wb ||= $con.workbook("#{File.dirname(File.expand_path(__FILE__))}/../resources/test.xlsx")
|
20
20
|
$temp_file_path ||= "#{Dir::tmpdir}/test.xlsx"
|
21
21
|
|
22
22
|
it '#name' do
|
data/test/unit/worksheet_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'time'
|
5
|
-
|
5
|
+
require 'jruby_excelcom'
|
6
6
|
|
7
7
|
describe 'Worksheet' do
|
8
8
|
|
@@ -11,9 +11,9 @@ describe 'Worksheet' do
|
|
11
11
|
e.display_alerts = false
|
12
12
|
e
|
13
13
|
end
|
14
|
-
$wb ||= $con.workbook("#{File.dirname(File.
|
14
|
+
$wb ||= $con.workbook("#{File.dirname(File.expand_path(__FILE__))}/../resources/test.xlsx")
|
15
15
|
|
16
|
-
Minitest.
|
16
|
+
Minitest::Unit.after_tests {
|
17
17
|
$wb.close unless $wb.nil?; $wb = nil
|
18
18
|
$con.quit unless $con.nil?; $con = nil
|
19
19
|
}
|
@@ -107,4 +107,12 @@ describe 'Worksheet' do
|
|
107
107
|
actual.must_equal color
|
108
108
|
end
|
109
109
|
|
110
|
+
it '#comment' do
|
111
|
+
range = 'A1'
|
112
|
+
comment = "test"
|
113
|
+
$ws.comment = {:range => range, :comment => comment}
|
114
|
+
actual = $ws.comment range
|
115
|
+
actual.must_equal comment
|
116
|
+
end
|
117
|
+
|
110
118
|
end
|
metadata
CHANGED
@@ -1,22 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby_excelcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- lprc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
12
|
-
dependencies:
|
11
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest-reporters
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.14'
|
13
41
|
description: Uses the java library excelcom and JNA for modifying excel spreadsheets.
|
14
42
|
Works on windows only.
|
15
|
-
email:
|
43
|
+
email:
|
16
44
|
executables: []
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- ".\\jruby_excelcom.gemspec"
|
20
49
|
- LICENSE
|
21
50
|
- doc/ExcelColor.html
|
22
51
|
- doc/ExcelConnection.html
|
@@ -73,7 +102,6 @@ files:
|
|
73
102
|
- doc/js/searcher.js
|
74
103
|
- doc/js/searcher.js.gz
|
75
104
|
- doc/table_of_contents.html
|
76
|
-
- jruby_excelcom.gemspec
|
77
105
|
- lib/jars/excelcom-0.0.6.jar
|
78
106
|
- lib/jars/jna-4.4.0.jar
|
79
107
|
- lib/jars/jna-platform-4.4.0.jar
|
@@ -87,11 +115,11 @@ files:
|
|
87
115
|
- test/unit/excel_connection_spec.rb
|
88
116
|
- test/unit/workbook_spec.rb
|
89
117
|
- test/unit/worksheet_spec.rb
|
90
|
-
homepage:
|
118
|
+
homepage: https://github.com/lprc/jruby_excelcom
|
91
119
|
licenses:
|
92
120
|
- Apache-2.0
|
93
121
|
metadata: {}
|
94
|
-
post_install_message:
|
122
|
+
post_install_message:
|
95
123
|
rdoc_options: []
|
96
124
|
require_paths:
|
97
125
|
- lib
|
@@ -106,9 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
134
|
- !ruby/object:Gem::Version
|
107
135
|
version: '0'
|
108
136
|
requirements: []
|
109
|
-
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
111
|
-
signing_key:
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.5.2
|
139
|
+
signing_key:
|
112
140
|
specification_version: 4
|
113
141
|
summary: Excel spreadsheet modification using COM
|
114
142
|
test_files: []
|