robust_excel_ole 1.24 → 1.29
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/Changelog +15 -0
- data/README.rdoc +22 -11
- data/bin/jreo +20 -1
- data/bin/reo +20 -1
- data/lib/robust_excel_ole.rb +2 -3
- data/lib/robust_excel_ole/address_tool.rb +2 -0
- data/lib/robust_excel_ole/base.rb +5 -0
- data/lib/robust_excel_ole/excel.rb +9 -9
- data/lib/robust_excel_ole/general.rb +154 -49
- data/lib/robust_excel_ole/list_object.rb +1 -1
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/general_spec.rb +27 -0
- data/spec/workbook_specs/workbook_unobtr_spec.rb +3 -3
- metadata +2 -5
- data/jreo.bat +0 -3
- data/lib/reo_console.rb +0 -97
- data/reo.bat +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73ad362b2dfdd26980d413527196770cd2fb7a48b62120c2f760534c34b50f63
|
4
|
+
data.tar.gz: 40913cb74eebf1f37a60eb54d3cae2d9ceaabaf21c9a8ce29a16c8a90d10be0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ee1041c26230fbf1d0406f2a4a7ac31116f01c3e28c40aa05d15f7fd19c78dcf27ca812c345e7dfe9f0c6aa8acb1ca5b48856565ec337e82e2a81cc7420a69d
|
7
|
+
data.tar.gz: 5606ffb364e94adbfb5654ef146ce67127a302d237c85422eaf0ca4a58fac4d6113798fb155bf316af6e6430d7b90ab4bd8971d5481993daef323996ae3d3d8c
|
data/Changelog
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [1.28] 2020-23-10
|
5
|
+
|
6
|
+
## [1.27] 2020-16-10
|
7
|
+
|
8
|
+
## [1.26] 2020-09-10
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- General#change_current_binding
|
12
|
+
|
13
|
+
## [1.25] 2020-10-09]
|
14
|
+
|
15
|
+
## [1.24] 2020-25-09
|
16
|
+
|
17
|
+
## [1.23] 2020-02-09
|
18
|
+
|
4
19
|
## [1.22] 2020-10-08
|
5
20
|
|
6
21
|
### Added
|
data/README.rdoc
CHANGED
@@ -64,15 +64,7 @@ If you want to start the console under jruby, and if you don't want to use a ver
|
|
64
64
|
|
65
65
|
jreo
|
66
66
|
|
67
|
-
The call of the console will include RobustExcelOle for you. The consoles require the ruby gem 'pry' and 'pry-bond' to enable the ruby shell 'pry' with filename and string completion.
|
68
|
-
|
69
|
-
object.pry
|
70
|
-
|
71
|
-
or
|
72
|
-
|
73
|
-
cd object
|
74
|
-
|
75
|
-
to assign self to this object. The original pry console is adapted to preserve local variables.
|
67
|
+
The call of the console will include RobustExcelOle for you. The consoles require the ruby gem 'pry' and 'pry-bond' to enable the ruby shell 'pry' with filename and string completion.
|
76
68
|
|
77
69
|
The following examples can be used for both scripts and console. If you have started the console in the gem path, you can just put these examples.
|
78
70
|
|
@@ -326,9 +318,28 @@ and set another value to that range.
|
|
326
318
|
For more details about reading and writing contents of cells and ranges see {README_ranges}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_ranges.rdoc]
|
327
319
|
|
328
320
|
|
329
|
-
=== More
|
321
|
+
=== More features
|
322
|
+
|
323
|
+
1. The method +General.change_current_binding+ allows to change the value of self within the current binding, while preserving the local variables, without starting another repl. Assume, +object+ shall be the self, then you would put
|
324
|
+
|
325
|
+
General.change_current_binding(object)
|
326
|
+
|
327
|
+
Without this method, the ruby shell 'pry' allows to change the value of 'self' in the console as well, e.g.
|
328
|
+
|
329
|
+
object.pry
|
330
|
+
|
331
|
+
or
|
332
|
+
|
333
|
+
cd object
|
334
|
+
|
335
|
+
However, this command also starts another pry repl (with another binding). Moreover, local variables in the previous binding are forgotten.
|
336
|
+
|
337
|
+
|
338
|
+
2. The class Win32Ole is being extended such that RobustExcelOle methods can be applied to Win32Ole objects. As mentioned above, the RobustExcelOle objects are wrapper of corresponding WIN32OLE objects. With help of +update_to_reo+ the RobustExcelOle objects and their wrapped Win32Ole objects are interchangeable. One example would be
|
339
|
+
|
340
|
+
range.ole_range.copy([4,3])
|
330
341
|
|
331
|
-
|
342
|
+
Likewise it is possible to convert ("type-lift") Win32Ole objects into the corresponding RobustExcelOle object, using General.to_reo.
|
332
343
|
|
333
344
|
range = sheet.Names.Item("firstcell").to_reo
|
334
345
|
|
data/bin/jreo
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- jruby -*-
|
3
3
|
|
4
4
|
require 'pry'
|
5
|
-
|
5
|
+
require_relative '../lib/robust_excel_ole'
|
6
6
|
|
7
7
|
include REO
|
8
8
|
include General
|
@@ -15,10 +15,29 @@ Pry.config.prompt_name = "REO "
|
|
15
15
|
#Pry.config.history_save = true
|
16
16
|
#Pry.editor = 'notepad' # 'subl', 'vi'
|
17
17
|
|
18
|
+
prompt_proc1 = proc { |target_self, nest_level, pry|
|
19
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
20
|
+
}
|
21
|
+
|
22
|
+
prompt_proc2 = proc { |target_self, nest_level, pry|
|
23
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect.gsub(/\"/, ''))})})#{":#{nest_level}" unless nest_level.zero?}* "
|
24
|
+
}
|
25
|
+
|
26
|
+
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
27
|
+
[prompt_proc1, prompt_proc2]
|
28
|
+
else
|
29
|
+
Pry::Prompt.new(
|
30
|
+
"REO",
|
31
|
+
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
32
|
+
[prompt_proc1, prompt_proc2]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
18
36
|
hooks = Pry::Hooks.new
|
19
37
|
|
20
38
|
hooks.add_hook :when_started, :hook12 do
|
21
39
|
puts 'REO console started'
|
22
40
|
puts
|
23
41
|
end
|
42
|
+
|
24
43
|
Pry.start(nil, hooks: hooks)
|
data/bin/reo
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'pry'
|
5
|
-
|
5
|
+
require_relative '../lib/robust_excel_ole'
|
6
6
|
|
7
7
|
include REO
|
8
8
|
include General
|
@@ -15,10 +15,29 @@ Pry.config.prompt_name = "REO "
|
|
15
15
|
#Pry.config.history_save = true
|
16
16
|
#Pry.editor = 'notepad' # 'subl', 'vi'
|
17
17
|
|
18
|
+
prompt_proc1 = proc { |target_self, nest_level, pry|
|
19
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
20
|
+
}
|
21
|
+
|
22
|
+
prompt_proc2 = proc { |target_self, nest_level, pry|
|
23
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
|
24
|
+
}
|
25
|
+
|
26
|
+
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
27
|
+
[prompt_proc1, prompt_proc2]
|
28
|
+
else
|
29
|
+
Pry::Prompt.new(
|
30
|
+
"REO",
|
31
|
+
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
32
|
+
[prompt_proc1, prompt_proc2]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
18
36
|
hooks = Pry::Hooks.new
|
19
37
|
|
20
38
|
hooks.add_hook :when_started, :hook12 do
|
21
39
|
puts 'REO console started'
|
22
40
|
puts
|
23
41
|
end
|
42
|
+
|
24
43
|
Pry.start(nil, hooks: hooks)
|
data/lib/robust_excel_ole.rb
CHANGED
@@ -3,8 +3,8 @@ if RUBY_PLATFORM =~ /java/
|
|
3
3
|
else
|
4
4
|
require 'win32ole'
|
5
5
|
end
|
6
|
-
require File.join(File.dirname(__FILE__), 'robust_excel_ole/base')
|
7
6
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/general')
|
7
|
+
require File.join(File.dirname(__FILE__), 'robust_excel_ole/base')
|
8
8
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/vba_objects')
|
9
9
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/range_owners')
|
10
10
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/address_tool')
|
@@ -18,5 +18,4 @@ require File.join(File.dirname(__FILE__), 'robust_excel_ole/list_object')
|
|
18
18
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/cygwin') if RUBY_PLATFORM =~ /cygwin/
|
19
19
|
require File.join(File.dirname(__FILE__), 'robust_excel_ole/version')
|
20
20
|
|
21
|
-
|
22
|
-
include General
|
21
|
+
General.init_reo_for_win32ole
|
@@ -76,7 +76,7 @@ module RobustExcelOle
|
|
76
76
|
end
|
77
77
|
connected = (not ole_xl.nil?) && win32ole_excel.nil?
|
78
78
|
ole_xl ||= WIN32OLE.new('Excel.Application')
|
79
|
-
hwnd = ole_xl.
|
79
|
+
hwnd = ole_xl.Hwnd
|
80
80
|
stored = hwnd2excel(hwnd)
|
81
81
|
if stored && stored.alive?
|
82
82
|
result = stored
|
@@ -297,7 +297,7 @@ module RobustExcelOle
|
|
297
297
|
finishing_living_excel = alive?
|
298
298
|
if finishing_living_excel
|
299
299
|
hwnd = (begin
|
300
|
-
@ole_excel.
|
300
|
+
@ole_excel.Hwnd
|
301
301
|
rescue
|
302
302
|
nil
|
303
303
|
end)
|
@@ -370,7 +370,7 @@ module RobustExcelOle
|
|
370
370
|
number = 0
|
371
371
|
WIN32OLE.connect('winmgmts:\\\\.').InstancesOf('win32_process').each do |p|
|
372
372
|
begin
|
373
|
-
if p.
|
373
|
+
if p.Name == 'EXCEL.EXE'
|
374
374
|
Process.kill('KILL', p.processid)
|
375
375
|
number += 1
|
376
376
|
end
|
@@ -384,7 +384,7 @@ module RobustExcelOle
|
|
384
384
|
|
385
385
|
def self.excels_number
|
386
386
|
processes = WIN32OLE.connect('winmgmts:\\\\.').InstancesOf('win32_process')
|
387
|
-
processes.select { |p| p.
|
387
|
+
processes.select { |p| p.Name == 'EXCEL.EXE' }.size
|
388
388
|
end
|
389
389
|
|
390
390
|
def self.known_excels_number
|
@@ -417,7 +417,7 @@ module RobustExcelOle
|
|
417
417
|
result.Visible # send any method, just to see if it responds
|
418
418
|
rescue
|
419
419
|
trace 'dead excel ' + (begin
|
420
|
-
"Window-handle = #{result.
|
420
|
+
"Window-handle = #{result.Hwnd}"
|
421
421
|
rescue
|
422
422
|
'without window handle'
|
423
423
|
end)
|
@@ -471,13 +471,13 @@ module RobustExcelOle
|
|
471
471
|
pid2excel[pid] = excel
|
472
472
|
end
|
473
473
|
processes = WIN32OLE.connect('winmgmts:\\\\.').InstancesOf('win32_process')
|
474
|
-
processes.select { |p| Excel.new(pid2excel[p.
|
474
|
+
processes.select { |p| Excel.new(pid2excel[p.ProcessId]) if p.Name == 'EXCEL.EXE' && pid2excel.include?(p.ProcessId) }
|
475
475
|
result = []
|
476
476
|
processes.each do |p|
|
477
|
-
next unless p.
|
477
|
+
next unless p.Name == 'EXCEL.EXE'
|
478
478
|
|
479
|
-
if pid2excel.include?(p.
|
480
|
-
excel = pid2excel[p.
|
479
|
+
if pid2excel.include?(p.ProcessId)
|
480
|
+
excel = pid2excel[p.ProcessId]
|
481
481
|
result << excel
|
482
482
|
end
|
483
483
|
# how to connect to an (interactively opened) Excel instance and get a WIN32OLE object?
|
@@ -3,14 +3,14 @@
|
|
3
3
|
module General
|
4
4
|
|
5
5
|
IS_JRUBY_PLATFORM = (RUBY_PLATFORM =~ /java/)
|
6
|
-
::EXPANDPATH_JRUBY_BUG
|
7
|
-
::CONNECT_JRUBY_BUG
|
8
|
-
::COPYSHEETS_JRUBY_BUG
|
9
|
-
::ERRORMESSAGE_JRUBY_BUG
|
10
|
-
::CONNECT_EXCEL_JRUBY_BUG
|
11
|
-
::RANGES_JRUBY_BUG
|
12
|
-
|
13
|
-
@private
|
6
|
+
::EXPANDPATH_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
7
|
+
::CONNECT_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
8
|
+
::COPYSHEETS_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
9
|
+
::ERRORMESSAGE_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
10
|
+
::CONNECT_EXCEL_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
11
|
+
::RANGES_JRUBY_BUG = IS_JRUBY_PLATFORM && true
|
12
|
+
|
13
|
+
# @private
|
14
14
|
NetworkDrive = Struct.new(:drive_letter, :network_name) do
|
15
15
|
|
16
16
|
def self.get_all(drives)
|
@@ -24,7 +24,7 @@ module General
|
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
-
@private
|
27
|
+
# @private
|
28
28
|
def hostnameshare2networkpath(filename)
|
29
29
|
return filename unless filename[0,2] == "//"
|
30
30
|
network = WIN32OLE.new('WScript.Network')
|
@@ -44,7 +44,7 @@ module General
|
|
44
44
|
file[0,2] = './' if ::EXPANDPATH_JRUBY_BUG && file =~ /[A-Z]:[^\/]/
|
45
45
|
file = File.expand_path(file)
|
46
46
|
file = RobustExcelOle::Cygwin.cygpath('-w', file) if RUBY_PLATFORM =~ /cygwin/
|
47
|
-
WIN32OLE.new('Scripting.FileSystemObject').GetAbsolutePathName(file)
|
47
|
+
WIN32OLE.new('Scripting.FileSystemObject').GetAbsolutePathName(file) #.tr('/','\\')
|
48
48
|
end
|
49
49
|
|
50
50
|
# @private
|
@@ -64,11 +64,102 @@ module General
|
|
64
64
|
path
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
def change_current_binding(current_object)
|
68
|
+
Pry.change_current_binding(current_object)
|
69
|
+
end
|
70
|
+
|
71
|
+
def class2method
|
72
|
+
[{RobustExcelOle::Excel => :Hwnd},
|
73
|
+
{RobustExcelOle::Workbook => :FullName},
|
74
|
+
{RobustExcelOle::Worksheet => :UsedRange},
|
75
|
+
{RobustExcelOle::Range => :Row},
|
76
|
+
{RobustExcelOle::ListObject => :ListRows}]
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
# enable RobustExcelOle methods to Win32Ole objects
|
81
|
+
def init_reo_for_win32ole
|
82
|
+
exclude_list = [:each, :each_with_index, :inspect, :Calculation=]
|
83
|
+
class2method.each do |element|
|
84
|
+
classname = element.first.first
|
85
|
+
classname.instance_methods(false).each do |inst_method|
|
86
|
+
if !exclude_list.include?(inst_method)
|
87
|
+
WIN32OLE.send(:define_method, inst_method) do |*args, &blk|
|
88
|
+
self.to_reo.send(inst_method, *args, &blk)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
|
96
|
+
module_function :absolute_path, :canonize, :normalize, :change_current_binding, :class2method,
|
97
|
+
:init_reo_for_win32ole, :hostnameshare2networkpath
|
68
98
|
|
69
99
|
end
|
70
100
|
|
101
|
+
|
71
102
|
# @private
|
103
|
+
class Pry
|
104
|
+
|
105
|
+
# change the current binding such that self is the current object in the pry-instance,
|
106
|
+
# preserve the local variables
|
107
|
+
|
108
|
+
class << self
|
109
|
+
attr_accessor :pry_instance
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.change_current_binding(current_object)
|
113
|
+
pry_instance = self.pry_instance
|
114
|
+
old_binding = pry_instance.binding_stack.pop
|
115
|
+
pry_instance.push_binding(current_object.__binding__)
|
116
|
+
exclude_vars = [:__, :_, :_dir, :_dir_, :_file, :_file_, :_in_, :_out_, :_ex, :_ex_, :pry_instance]
|
117
|
+
old_binding.local_variables.each do |var|
|
118
|
+
pry_instance.add_sticky_local(var) {old_binding.local_variable_get(var)} unless exclude_vars.include?(var)
|
119
|
+
end
|
120
|
+
self.pry_instance = pry_instance
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def push_initial_binding(target = nil)
|
125
|
+
# memorize the current pry instance
|
126
|
+
self.class.pry_instance = self
|
127
|
+
push_binding(target || Pry.toplevel_binding)
|
128
|
+
end
|
129
|
+
|
130
|
+
class REPL
|
131
|
+
|
132
|
+
def read
|
133
|
+
@indent.reset if pry.eval_string.empty?
|
134
|
+
current_prompt = pry.select_prompt
|
135
|
+
indentation = pry.config.auto_indent ? @indent.current_prefix : ''
|
136
|
+
val = read_line("#{current_prompt}#{indentation}")
|
137
|
+
# Return nil for EOF, :no_more_input for error, or :control_c for <Ctrl-C>
|
138
|
+
return val unless val.is_a?(String)
|
139
|
+
if pry.config.auto_indent
|
140
|
+
original_val = "#{indentation}#{val}"
|
141
|
+
indented_val = @indent.indent(val)
|
142
|
+
|
143
|
+
if output.tty? &&
|
144
|
+
pry.config.correct_indent &&
|
145
|
+
Pry::Helpers::BaseHelpers.use_ansi_codes?
|
146
|
+
# avoid repeating read line
|
147
|
+
|
148
|
+
#output.print @indent.correct_indentation(
|
149
|
+
# current_prompt,
|
150
|
+
# indented_val,
|
151
|
+
# calculate_overhang(current_prompt, original_val, indented_val)
|
152
|
+
#)
|
153
|
+
output.flush
|
154
|
+
end
|
155
|
+
else
|
156
|
+
indented_val = val
|
157
|
+
end
|
158
|
+
indented_val
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
72
163
|
class Integer
|
73
164
|
|
74
165
|
alias old_spaceship <=>
|
@@ -111,6 +202,57 @@ class Array
|
|
111
202
|
end
|
112
203
|
end
|
113
204
|
|
205
|
+
=begin
|
206
|
+
# @private
|
207
|
+
module RefinedSpaceship
|
208
|
+
|
209
|
+
refine Integer do
|
210
|
+
|
211
|
+
alias old_spaceship <=>
|
212
|
+
|
213
|
+
def <=> other
|
214
|
+
# p other
|
215
|
+
if other.is_a? Array
|
216
|
+
self <=> other.first
|
217
|
+
else
|
218
|
+
old_spaceship other
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
refine Array do
|
224
|
+
|
225
|
+
alias old_spaceship <=>
|
226
|
+
|
227
|
+
def <=> other
|
228
|
+
# p other
|
229
|
+
if other.is_a? Integer
|
230
|
+
self <=> [other]
|
231
|
+
else
|
232
|
+
old_spaceship other
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
=end
|
238
|
+
|
239
|
+
# @private
|
240
|
+
class Array
|
241
|
+
|
242
|
+
def find_all_indices elem
|
243
|
+
found, index, result = -1, -1, []
|
244
|
+
while found
|
245
|
+
found = self[index+1..-1].index(elem)
|
246
|
+
if found
|
247
|
+
index = index + found + 1
|
248
|
+
result << index
|
249
|
+
end
|
250
|
+
end
|
251
|
+
result
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
|
114
256
|
# @private
|
115
257
|
class WIN32OLE
|
116
258
|
|
@@ -118,14 +260,7 @@ class WIN32OLE
|
|
118
260
|
|
119
261
|
# type-lifting WIN32OLE objects to RobustExcelOle objects
|
120
262
|
def to_reo
|
121
|
-
class2method
|
122
|
-
{Excel => :Hwnd},
|
123
|
-
{Workbook => :FullName},
|
124
|
-
{Worksheet => :UsedRange},
|
125
|
-
{RobustExcelOle::Range => :Row},
|
126
|
-
{ListObject => :ListRows}
|
127
|
-
]
|
128
|
-
class2method.each do |element|
|
263
|
+
General.class2method.each do |element|
|
129
264
|
classname = element.first.first
|
130
265
|
method = element.first.last
|
131
266
|
begin
|
@@ -142,33 +277,6 @@ class WIN32OLE
|
|
142
277
|
raise TypeREOError, "given object cannot be type-lifted to a RobustExcelOle object"
|
143
278
|
end
|
144
279
|
|
145
|
-
|
146
|
-
# def method_missing(name, *args, &blk)
|
147
|
-
# puts "method_missing:"
|
148
|
-
# puts "name: #{name.inspect}"
|
149
|
-
# puts "self: #{self}"
|
150
|
-
# puts "self.ole_type: #{self.ole_type}"
|
151
|
-
# puts "self.to_reo: #{self.to_reo}"
|
152
|
-
# begin
|
153
|
-
# reo_obj = self.to_reo
|
154
|
-
# rescue
|
155
|
-
# puts "error: #{$!.message}"
|
156
|
-
# raise # NoMethodError, "undefined method #{name.inspect} for #{self.inspect}"
|
157
|
-
# end
|
158
|
-
# reo_obj.send(name, *args, &blk)
|
159
|
-
# end
|
160
|
-
|
161
|
-
#alias method_missing_before_implicit_typelift method_missing
|
162
|
-
#def method_missing(name, *args, &blk)
|
163
|
-
# begin
|
164
|
-
# reo_obj = self.to_reo
|
165
|
-
# rescue
|
166
|
-
# puts "$!.message: #{$!.message}"
|
167
|
-
# method_missing_before_implicit_typelift(name, *args, &blk)
|
168
|
-
# end
|
169
|
-
# reo_obj.send(name, *args, &blk)
|
170
|
-
#end
|
171
|
-
|
172
280
|
end
|
173
281
|
|
174
282
|
# @private
|
@@ -293,7 +401,4 @@ module MethodHelpers
|
|
293
401
|
super
|
294
402
|
end
|
295
403
|
end
|
296
|
-
|
297
404
|
end
|
298
|
-
|
299
|
-
REO = RobustExcelOle
|
@@ -351,7 +351,7 @@ module RobustExcelOle
|
|
351
351
|
listrows = @ole_table.ListRows
|
352
352
|
result = []
|
353
353
|
(1..listrows.Count).each do |row_number|
|
354
|
-
row_values(row_number).
|
354
|
+
row_values(row_number).find_all_indices(value).each do |col_number|
|
355
355
|
result << @ole_table.Application.Intersect(listrows.Item(row_number).Range,
|
356
356
|
@ole_table.ListColumns.Item(col_number+1).Range).to_reo
|
357
357
|
end
|
Binary file
|
data/spec/general_spec.rb
CHANGED
@@ -96,6 +96,33 @@ module RobustExcelOle
|
|
96
96
|
|
97
97
|
end
|
98
98
|
|
99
|
+
describe "General.init_reo_for_win32ole" do
|
100
|
+
|
101
|
+
before do
|
102
|
+
@book1 = Workbook.open(@simple_file, :visible => true)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should apply reo-methods to win32ole objects" do
|
106
|
+
ole_book1 = @book1.ole_workbook
|
107
|
+
sheet1 = ole_book1.sheet(1)
|
108
|
+
sheet1.should be_a Worksheet
|
109
|
+
sheet1.name.should == "Sheet1"
|
110
|
+
ole_sheet1 = sheet1.ole_worksheet
|
111
|
+
range1 = ole_sheet1.range([1..2,3..4])
|
112
|
+
range1.should be_a RobustExcelOle::Range
|
113
|
+
range1.value.should == [["sheet1",nil],["foobaaa",nil]]
|
114
|
+
ole_range1 = range1.ole_range
|
115
|
+
ole_range1.copy([6,6])
|
116
|
+
range2 = sheet1.range([6..7,6..7])
|
117
|
+
range2.value.should == [["sheet1",nil],["foobaaa",nil]]
|
118
|
+
excel1 = @book1.excel
|
119
|
+
ole_excel1 = excel1.ole_excel
|
120
|
+
ole_excel1.close(:if_unsaved => :forget)
|
121
|
+
Excel.kill_all
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
99
126
|
describe "methods, own_methods, respond_to?" do
|
100
127
|
|
101
128
|
before do
|
@@ -935,7 +935,7 @@ describe Workbook do
|
|
935
935
|
book.ReadOnly.should be true
|
936
936
|
book.should == @book
|
937
937
|
book.filename.should == @book.filename
|
938
|
-
book.excel.
|
938
|
+
book.excel.should == @book.excel
|
939
939
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
940
940
|
end
|
941
941
|
}.to raise_error(WorkbookReadOnly)
|
@@ -1013,7 +1013,7 @@ describe Workbook do
|
|
1013
1013
|
book.Readonly.should be false
|
1014
1014
|
book.should == @book
|
1015
1015
|
book.filename.should == @book.filename
|
1016
|
-
book.excel.
|
1016
|
+
book.excel.should == @book.excel
|
1017
1017
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
1018
1018
|
end
|
1019
1019
|
@book.close
|
@@ -1026,7 +1026,7 @@ describe Workbook do
|
|
1026
1026
|
book.Readonly.should be false
|
1027
1027
|
book.should == @book
|
1028
1028
|
book.filename.should == @book.filename
|
1029
|
-
book.excel.
|
1029
|
+
book.excel.should == @book.excel
|
1030
1030
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
1031
1031
|
end
|
1032
1032
|
@book.close
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.29'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- traths
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -126,8 +126,6 @@ files:
|
|
126
126
|
- examples/open_save_close/example_reuse.rb
|
127
127
|
- examples/open_save_close/example_simple.rb
|
128
128
|
- examples/open_save_close/example_unobtrusively.rb
|
129
|
-
- jreo.bat
|
130
|
-
- lib/reo_console.rb
|
131
129
|
- lib/robust_excel_ole.rb
|
132
130
|
- lib/robust_excel_ole/address_tool.rb
|
133
131
|
- lib/robust_excel_ole/base.rb
|
@@ -149,7 +147,6 @@ files:
|
|
149
147
|
- lib/robust_excel_ole/workbook.rb
|
150
148
|
- lib/robust_excel_ole/worksheet.rb
|
151
149
|
- lib/spec_helper.rb
|
152
|
-
- reo.bat
|
153
150
|
- robust_excel_ole.gemspec
|
154
151
|
- spec/address_tool_spec.rb
|
155
152
|
- spec/base_spec.rb
|
data/jreo.bat
DELETED
data/lib/reo_console.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'pry'
|
2
|
-
require '../robust_excel_ole/lib/robust_excel_ole'
|
3
|
-
|
4
|
-
include REO
|
5
|
-
include General
|
6
|
-
|
7
|
-
# pry mit behalten lokaler Variablen
|
8
|
-
|
9
|
-
class Object
|
10
|
-
|
11
|
-
def pry(object = nil, hash = {})
|
12
|
-
@local_vars ||= { }
|
13
|
-
if object.nil? || Hash === object # rubocop:disable Style/CaseEquality
|
14
|
-
Pry.start(self, object || {})
|
15
|
-
else
|
16
|
-
Pry.start(object, hash)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class Pry
|
23
|
-
|
24
|
-
def self.set_local_vars local_vars
|
25
|
-
@local_vars = local_vars
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.get_local_vars
|
29
|
-
@local_vars
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.binding_for(target)
|
33
|
-
return target if Binding === target # rubocop:disable Style/CaseEquality
|
34
|
-
return TOPLEVEL_BINDING if Pry.main == target
|
35
|
-
__bnd = target.instance_eval{ target.__binding__ }
|
36
|
-
@local_vars.each{ |var,value| __bnd.local_variable_set(var, value) }
|
37
|
-
#target.__binding__
|
38
|
-
__bnd
|
39
|
-
end
|
40
|
-
|
41
|
-
class REPL
|
42
|
-
|
43
|
-
def repl
|
44
|
-
loop do
|
45
|
-
case val = read
|
46
|
-
when :control_c
|
47
|
-
output.puts ""
|
48
|
-
pry.reset_eval_string
|
49
|
-
when :no_more_input
|
50
|
-
output.puts "" if output.tty?
|
51
|
-
break
|
52
|
-
else
|
53
|
-
output.puts "" if val.nil? && output.tty?
|
54
|
-
# determine the local variables in the binding before evaluation
|
55
|
-
bnd = pry.binding_stack.first
|
56
|
-
exclude_vars = [:__, :_, :_dir, :_dir_, :_file, :_file_, :_in_, :_out_, :_ex, :_ex_, :pry_instance]
|
57
|
-
local_vars = Pry.get_local_vars
|
58
|
-
bnd.local_variables.each{ |var| local_vars[var] = bnd.local_variable_get(var) unless exclude_vars.include?(var) }
|
59
|
-
Pry.set_local_vars(local_vars)
|
60
|
-
return pry.exit_value unless pry.eval(val)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
# some pry configuration
|
69
|
-
Pry.config.windows_console_warning = false
|
70
|
-
Pry.config.color = false
|
71
|
-
Pry.config.prompt_name = "REO "
|
72
|
-
|
73
|
-
#Pry.config.history_save = true
|
74
|
-
#Pry.editor = 'notepad' # 'subl', 'vi'
|
75
|
-
|
76
|
-
Pry.config.prompt = Pry::Prompt.new(
|
77
|
-
"REO",
|
78
|
-
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
79
|
-
[
|
80
|
-
proc { |target_self, nest_level, pry|
|
81
|
-
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}> "
|
82
|
-
},
|
83
|
-
|
84
|
-
proc { |target_self, nest_level, pry|
|
85
|
-
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}* "
|
86
|
-
}
|
87
|
-
]
|
88
|
-
)
|
89
|
-
|
90
|
-
|
91
|
-
hooks = Pry::Hooks.new
|
92
|
-
|
93
|
-
hooks.add_hook :when_started, :hook12 do
|
94
|
-
puts 'REO console started'
|
95
|
-
puts
|
96
|
-
end
|
97
|
-
Pry.start(nil, hooks: hooks)
|
data/reo.bat
DELETED