robust_excel_ole 1.22.2 → 1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d60404c6338fa948418c3381d8f83b80147861694abd07956009fd332c923bc7
4
- data.tar.gz: 1f50eae2f0c909a712563dd6ae2df38e45d9924ece79f1915987346bc3b6d1e1
3
+ metadata.gz: d73c62c763182694dfebd8d6c08aff0c4202752cb27dd7d8b7b46f6c1960ca4d
4
+ data.tar.gz: f3381ababd070bf4f9c19a7a244d7a763d4bb97893c75b36770e27ee0b051bc5
5
5
  SHA512:
6
- metadata.gz: c5067ff3c58c8d9e83715db4cdba7ffd18305b27e77eb8e9b420f91fdffba784c6545453419e23af643372d1e16b2d328ef839ae7fb75b927611f235d2deab2c
7
- data.tar.gz: 78080f4450242c98edb442d8a519ae2a0713fb3bedaf5fdb7500e8b9430856dace574f79d98bc45faedc72b0267bbf11e068d71a3e7dab2121a22c6188e70792
6
+ metadata.gz: 86e25e6d15f705b8a44058050d2a6360da2581a72855ed552a8f30958a6da707fcddb18d661416b63fa721e864bc57e6ee4102ca7a4d5569182569353538e38a
7
+ data.tar.gz: 28daa6be28ba71b70ece8a387cac4e06441232e5ada825970338faaf4e0a269da1c32a471ea0d38eaa2c704f438281be7db127a8a7a257d2aa4b79d784f4547a
data/Changelog CHANGED
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## [1.22] 2020-10-08
5
5
 
6
+ ### Added
7
+ - Range#set_value
8
+
6
9
  ## [1.21] 2020-05-08
7
10
 
8
11
  ### Added
@@ -64,7 +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.
67
+ The call of the console will include RobustExcelOle for you. The consoles require the ruby gem 'pry'. If you want to use the nice feature of filename and string completion, you may install pry-bond as well.
68
68
 
69
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.
70
70
 
data/bin/jreo CHANGED
@@ -2,21 +2,18 @@
2
2
  # -*- jruby -*-
3
3
 
4
4
  require 'pry'
5
- require 'robust_excel_ole'
5
+ require '../robust_excel_ole/lib/robust_excel_ole'
6
6
 
7
7
  include REO
8
8
  include General
9
9
 
10
10
  # some pry configuration
11
11
  Pry.config.windows_console_warning = false
12
- #Pry.config.history_save = true
13
12
  Pry.config.color = false
13
+ Pry.config.prompt_name = "REO "
14
+
15
+ #Pry.config.history_save = true
14
16
  #Pry.editor = 'notepad' # 'subl', 'vi'
15
- #Pry.config.prompt =
16
- #[
17
- #->(_obj, _nest_level, _) { ">> " },
18
- #->(*) { " " }
19
- #]
20
17
 
21
18
  hooks = Pry::Hooks.new
22
19
 
data/bin/reo CHANGED
@@ -2,21 +2,18 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'pry'
5
- require 'robust_excel_ole'
5
+ require '../robust_excel_ole/lib/robust_excel_ole'
6
6
 
7
7
  include REO
8
8
  include General
9
9
 
10
10
  # some pry configuration
11
11
  Pry.config.windows_console_warning = false
12
- #Pry.config.history_save = true
13
12
  Pry.config.color = false
13
+ Pry.config.prompt_name = "REO "
14
+
15
+ #Pry.config.history_save = true
14
16
  #Pry.editor = 'notepad' # 'subl', 'vi'
15
- #Pry.config.prompt =
16
- #[
17
- #->(_obj, _nest_level, _) { ">> " },
18
- #->(*) { " " }
19
- #]
20
17
 
21
18
  hooks = Pry::Hooks.new
22
19
 
@@ -42,14 +42,18 @@ or
42
42
 
43
43
  range = worksheet.range(["A1:D3"])
44
44
 
45
- You can read the values by
45
+ You can also access a range from a workbook by providing the worksheet
46
+
47
+ range = workbook(workbook.sheet(1), [1..3,1..4])
48
+
49
+ Now you can read the values by
46
50
 
47
51
  range.Value
48
52
  => [["foo", "workbook", "sheet1", nil], ["foo", nil, "foobaaa", nil], ["matz", "is", "nice", nil]]
49
53
 
50
54
  or
51
55
 
52
- range.v
56
+ range.value or range.v
53
57
  => [["foo", "workbook", "sheet1", nil], ["foo", nil, "foobaaa", nil], ["matz", "is", "nice", nil]]
54
58
 
55
59
  or as flat array
@@ -63,8 +67,20 @@ You can set values with help of range#Value or range#v, e.g.
63
67
 
64
68
  or
65
69
 
70
+ range.value = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
71
+
72
+ or
73
+
66
74
  range.v = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
67
75
 
76
+ or
77
+
78
+ range.set_value([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
79
+
80
+ You can color the range when setting the contents of a range.
81
+
82
+ range.set_value([[1,2,3,4],[5,6,7,8],[9,10,11,12]], :color => 42)
83
+
68
84
  Now we copy the range. With help of VBA methods you would do
69
85
 
70
86
  range.Copy(:destination => sheet.range([4,5]).ole_range)
@@ -194,6 +210,10 @@ or
194
210
 
195
211
  range = worksheet.range([[1]..3,2..[4]])
196
212
 
213
+ You can access a range also from a workbook by providing the respective worksheet
214
+
215
+ range = workbook(worksheet, [[1..3],2..[4]])
216
+
197
217
  You get the values of the range as flat array with help of
198
218
 
199
219
  range.values
@@ -202,6 +222,10 @@ You can access a range via its defined name with
202
222
 
203
223
  range = worksheet.range("name")
204
224
 
225
+ or
226
+
227
+ range = workbook(worksheet, "name")
228
+
205
229
  === Copying a range
206
230
 
207
231
  Let's assume, you have a source range
@@ -310,10 +334,6 @@ You can color the range when setting the contents of a range.
310
334
 
311
335
  workbook.set_namevalue_glob("name", "new_value", :color => 4)
312
336
 
313
- The method []= sets the contents of a range and colors the range via some default color.
314
-
315
- workbook["name"] = "new_value"
316
-
317
337
  Similarly, the contents of a named range can be read and modified in a worksheet
318
338
 
319
339
  worksheet = workbook.sheet(1)
@@ -97,7 +97,7 @@ The method Worksheet#values yields all cell values of the used range of the work
97
97
  worksheet.values
98
98
  => [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"], ["matz", "is", "nice"]]
99
99
 
100
- The method Worksheet#each_rowvalue provides enable to access the values of each row.
100
+ The method Worksheet#each_rowvalue enables to access the values of each row.
101
101
 
102
102
  worksheet.each_rowvalue do |row_values|
103
103
  # do something with the row_values
@@ -6,14 +6,11 @@ include General
6
6
 
7
7
  # some pry configuration
8
8
  Pry.config.windows_console_warning = false
9
- #Pry.config.history_save = true
10
9
  Pry.config.color = false
10
+ Pry.config.prompt_name = "REO "
11
+
12
+ #Pry.config.history_save = true
11
13
  #Pry.editor = 'notepad' # 'subl', 'vi'
12
- #Pry.config.prompt =
13
- #[
14
- #->(_obj, _nest_level, _) { ">> " },
15
- #->(*) { " " }
16
- #]
17
14
 
18
15
  hooks = Pry::Hooks.new
19
16
 
@@ -18,5 +18,5 @@ 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
- include RobustExcelOle
21
+ #include RobustExcelOle
22
22
  include General
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ LOG_TO_STDOUT: Boolean = false
4
+ REO_LOG_DIR: String
5
+ REO_LOG_FILE: String
6
+
7
+ class String
8
+
9
+ def end_with? : (suffixes: Array[String]) -> String
10
+
11
+ end
12
+
13
+ module RobustExcelOle
14
+
15
+ class VBAMethodMissingError < RuntimeError
16
+ end
17
+
18
+ class REOError < RuntimeError
19
+ end
20
+
21
+ class ExcelREOError < REOError
22
+ end
23
+
24
+ class WorkbookREOError < REOError
25
+ end
26
+
27
+ class WorksheetREOError < REOError
28
+ end
29
+
30
+ class FileREOError < REOError
31
+ end
32
+
33
+ class NamesREOError < REOError
34
+ end
35
+
36
+ class MiscREOError < REOError
37
+ end
38
+
39
+ class TypeREOError < REOError
40
+ end
41
+
42
+ # @private
43
+ class UnexpectedREOError < REOError
44
+ end
45
+
46
+ # @private
47
+ class NotImplementedREOError < REOError
48
+ end
49
+
50
+
51
+ class Base
52
+
53
+ def own_methods -> Array[Symbol]
54
+
55
+ def self.tr1: (_text1: String) -> void
56
+
57
+ def self.trace: (text: String) -> void
58
+
59
+ def self.puts_hash: (hash: Hash) -> void
60
+
61
+ end
62
+
63
+ end
@@ -12,14 +12,17 @@ module RobustExcelOle
12
12
  ole_cell
13
13
  end
14
14
 
15
- def v
15
+ def value
16
16
  self.Value
17
17
  end
18
18
 
19
- def v=(value)
19
+ def value=(value)
20
20
  self.Value = value
21
21
  end
22
22
 
23
+ alias_method :v, :value
24
+ alias_method :v=, :value=
25
+
23
26
  # @private
24
27
  def ole_cell
25
28
  @ole_range = @ole_range.MergeArea.Item(1,1) if @ole_range.MergeCells
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module RobustExcelOle
4
+
5
+ class Cell < Range
6
+
7
+ def initialize: (win32_cell: WIN32OLE, worksheet: Worksheet) -> void
8
+
9
+ def value -> String
10
+
11
+ def value= (value: Variant) -> Variant
12
+
13
+ def v -> String
14
+
15
+ def v= (value: Variant) -> Variant
16
+
17
+ def ole_cell -> WIN32OLE | void
18
+
19
+ def to_s -> String
20
+
21
+ def inspect -> String
22
+
23
+ end
24
+
25
+ end
@@ -640,13 +640,8 @@ module RobustExcelOle
640
640
  # set options in this Excel instance
641
641
  def for_this_instance(options)
642
642
  set_options(options)
643
- #self.class.new(@ole_excel, options)
644
643
  end
645
644
 
646
- #def set_options(options)
647
- # for_this_instance(options)
648
- #end
649
-
650
645
  def set_options(options)
651
646
  @properties ||= { }
652
647
  PROPERTIES.each do |property|
@@ -17,23 +17,30 @@ module RobustExcelOle
17
17
  alias ole_object ole_table
18
18
 
19
19
  # constructs a list object (or table).
20
- # @param [Variable] worksheet_or_ole_listobject a worksheet or a Win32Ole list object
20
+ # @param [Variable] worksheet_or_listobject a worksheet or a list object
21
21
  # @param [Variable] table_name_or_number a table name or table number
22
22
  # @param [Array] position a position of the upper left corner
23
23
  # @param [Integer] rows_count number of rows
24
24
  # @param [Variable] columns_count_or_names number of columns or array of column names
25
25
  # @return [ListObject] a ListObject object
26
- def initialize(worksheet_or_ole_listobject,
27
- table_name_or_number = "",
26
+ def initialize(worksheet_or_listobject,
27
+ table_name_or_number = "_table_name",
28
28
  position = [1,1],
29
29
  rows_count = 1,
30
30
  columns_count_or_names = 1)
31
-
32
- if (worksheet_or_ole_listobject.ListRows rescue nil)
33
- @ole_table = worksheet_or_ole_listobject
31
+
32
+ # ole_table is being assigned to the first parameter, if this parameter is a ListObject
33
+ # otherwise the first parameter could be a worksheet, and get the ole_table via the ListObject name or number
34
+ @ole_table = if worksheet_or_listobject.respond_to?(:ListRows)
35
+ worksheet_or_listobject.ole_table
34
36
  else
35
- @worksheet = worksheet_or_ole_listobject.to_reo
36
- @ole_table = @worksheet.ListObjects.Item(table_name_or_number) rescue nil
37
+ begin
38
+ worksheet_or_listobject.send(:ListRows)
39
+ worksheet_or_listobject
40
+ rescue
41
+ @worksheet = worksheet_or_listobject.to_reo
42
+ @worksheet.ListObjects.Item(table_name_or_number) rescue nil
43
+ end
37
44
  end
38
45
  unless @ole_table
39
46
  columns_count =
@@ -52,6 +59,7 @@ module RobustExcelOle
52
59
  end
53
60
  end
54
61
 
62
+
55
63
  ole_table = @ole_table
56
64
  @row_class = Class.new(ListRow) do
57
65
 
@@ -5,7 +5,7 @@ module RobustExcelOle
5
5
  # This class essentially wraps a Win32Ole Range object.
6
6
  # You can apply all VBA methods (starting with a capital letter)
7
7
  # that you would apply for a Range object.
8
- # See https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet#methods
8
+ # See https://docs.microsoft.com/en-us/office/vba/api/excel.range#methods
9
9
 
10
10
  class Range < VbaObjects
11
11
 
@@ -70,7 +70,9 @@ module RobustExcelOle
70
70
  end
71
71
  end
72
72
 
73
- def v
73
+ # returns flat array of the values of a given range
74
+ # @returns [Array] values of the range (as a nested array)
75
+ def value
74
76
  begin
75
77
  if !::RANGES_JRUBY_BUG
76
78
  self.Value
@@ -89,7 +91,9 @@ module RobustExcelOle
89
91
 
90
92
  end
91
93
 
92
- def v=(value)
94
+ # sets the values if the range
95
+ # @param [Variant] value
96
+ def value=(value)
93
97
  begin
94
98
  if !::RANGES_JRUBY_BUG
95
99
  ole_range.Value = value
@@ -102,12 +106,33 @@ module RobustExcelOle
102
106
  end
103
107
  value
104
108
  rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException => msg
105
- raise RangeNotEvaluatable, "cannot assign value to range #{address_r1c1.inspect}"
109
+ raise RangeNotEvaluatable, "cannot assign value to range #{self.inspect}"
106
110
  end
107
111
  end
108
112
 
109
- alias_method :value, :v
110
- alias_method :value=, :v=
113
+ alias_method :v, :value
114
+ alias_method :v=, :value=
115
+
116
+ # sets the values if the range with a given color
117
+ # @param [Variant] value
118
+ # @option opts [Symbol] :color the color of the cell when set
119
+ def set_value(value, opts = { })
120
+ begin
121
+ if !::RANGES_JRUBY_BUG
122
+ ole_range.Value = value
123
+ else
124
+ rows.each_with_index do |r,i|
125
+ columns.each_with_index do |c,j|
126
+ ole_range.Cells(i+1,j+1).Value = (value.respond_to?(:first) ? value[i][j] : value)
127
+ end
128
+ end
129
+ end
130
+ ole_range.Interior.ColorIndex = opts[:color] unless opts[:color].nil?
131
+ value
132
+ rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException => msg
133
+ raise RangeNotEvaluatable, "cannot assign value to range #{self.inspect}"
134
+ end
135
+ end
111
136
 
112
137
  # copies a range
113
138
  # @params [Address or Address-Array] address or upper left position of the destination range
@@ -189,12 +214,11 @@ module RobustExcelOle
189
214
  # @private
190
215
  def to_s
191
216
  "#<REO::Range: " + "#{@ole_range.Address('External' => true).gsub(/\$/,'')} " + ">"
192
- # "#<REO::Range: " + "#{@ole_range.Address.gsub(/\$/,'')} " + "#{worksheet.Name} " + ">"
193
217
  end
194
218
 
195
219
  # @private
196
220
  def inspect
197
- to_s # [0..-2] + "#{worksheet.workbook.Name} " + ">"
221
+ to_s
198
222
  end
199
223
 
200
224
  # @private
@@ -62,7 +62,7 @@ module RobustExcelOle
62
62
  # sets the contents of a range
63
63
  # @param [String] name the name of a range
64
64
  # @param [Variant] value the contents of the range
65
- # @option opts [Symbol] :color the color of the cell when set
65
+ # @option opts [Symbol] :color the color of the range when set
66
66
  def set_namevalue_glob(name, value, opts = { })
67
67
  begin
68
68
  name_obj = begin
@@ -177,36 +177,10 @@ module RobustExcelOle
177
177
  end
178
178
 
179
179
  # creates a range from a given defined name or address
180
- # range(address) does work for Worksheet objects only
181
- # @params [Variant] range name or address
180
+ # @params [Variant] defined name or address, and optional a worksheet
182
181
  # @return [Range] a range
183
- def range(name_or_address, address2 = :__not_provided)
184
- begin
185
- worksheet = self if self.is_a?(Worksheet)
186
- if address2 == :__not_provided
187
- range = if name_or_address.is_a?(String)
188
- begin
189
- RobustExcelOle::Range.new(name_object(name_or_address).RefersToRange, worksheet)
190
- rescue NameNotFound
191
- nil
192
- end
193
- end
194
- end
195
- if self.is_a?(Worksheet) && (range.nil? || (address2 != :__not_provided))
196
- address = name_or_address
197
- address = [name_or_address,address2] unless address2 == :__not_provided
198
- self.Names.Add('__dummy001',nil,true,nil,nil,nil,nil,nil,nil,'=' + address_tool.as_r1c1(address))
199
- range = RobustExcelOle::Range.new(name_object('__dummy001').RefersToRange, worksheet)
200
- self.Names.Item('__dummy001').Delete
201
- workbook = self.is_a?(Workbook) ? self : self.workbook
202
- workbook.save
203
- range
204
- end
205
- rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException
206
- address2_string = address2.nil? ? "" : ", #{address2.inspect}"
207
- raise RangeNotCreated, "cannot create range (#{name_or_address.inspect}#{address2_string})"
208
- end
209
- range
182
+ def range(*args)
183
+ raise RangeNotCreated, "not yet implemented"
210
184
  end
211
185
 
212
186
  def name2range(name) # :deprecated: #
@@ -0,0 +1,23 @@
1
+
2
+ # -*- coding: utf-8 -*-
3
+
4
+ module RobustExcelOle
5
+
6
+ class VbaObjects < Base
7
+
8
+ def to_reo -> VbaObjects
9
+
10
+ def address_tool -> AddressTool
11
+
12
+ end
13
+
14
+ class RangeNotEvaluatable < MiscREOError
15
+ end
16
+
17
+ class OptionInvalid < MiscREOError
18
+ end
19
+
20
+ class ObjectNotAlive < MiscREOError
21
+ end
22
+
23
+ end
@@ -1,3 +1,3 @@
1
1
  module RobustExcelOle
2
- VERSION = "1.22.2"
2
+ VERSION = "1.23"
3
3
  end
@@ -882,6 +882,24 @@ module RobustExcelOle
882
882
  worksheet_class.new(@ole_workbook.Worksheets.Item(1))
883
883
  end
884
884
 
885
+ # creates a range from a given defined name or from a given worksheet and address
886
+ # @params [Variant] defined name or a worksheet
887
+ # @params [Address] address
888
+ # @return [Range] a range
889
+ def range(name_or_worksheet, name_or_address = :__not_provided, address2 = :__not_provided)
890
+ if name_or_worksheet.respond_to?(:gsub)
891
+ name = name_or_worksheet
892
+ RobustExcelOle::Range.new(name_object(name).RefersToRange)
893
+ else
894
+ begin
895
+ worksheet = name_or_worksheet.to_reo
896
+ worksheet.range(name_or_address, address2)
897
+ rescue
898
+ raise RangeNotCreated, "argument error: a defined name or a worksheet and an address must be provided"
899
+ end
900
+ end
901
+ end
902
+
885
903
  # returns the value of a range
886
904
  # @param [String] name the name of a range
887
905
  # @returns [Variant] the value of the range
@@ -64,7 +64,7 @@ module RobustExcelOle
64
64
  end
65
65
  end
66
66
 
67
- # a cell given the defined name or row and column
67
+ # returns a cell given the defined name or row and column
68
68
  # @params row, column, or name
69
69
  # @returns cell, if row and column are given
70
70
  def [] p1, p2 = :__not_provided
@@ -118,19 +118,6 @@ module RobustExcelOle
118
118
  end
119
119
  end
120
120
 
121
- =begin
122
- def cellval(x,y)
123
- xy = "#{x}_#{y}"
124
- @cells = { }
125
- begin
126
- @cells[xy] ||= RobustExcelOle::Cell.new(@ole_worksheet.Cells.Item(x, y), @worksheet)
127
- @cells[xy].Value
128
- rescue
129
- raise RangeNotEvaluatable, "cannot read cell (#{p1.inspect},#{p2.inspect})"
130
- end
131
- end
132
- =end
133
-
134
121
  # sets the value of a cell, if row, column and color of the cell are given
135
122
  # @params [Integer] x,y row and column
136
123
  # @option opts [Symbol] :color the color of the cell when set
@@ -226,6 +213,31 @@ module RobustExcelOle
226
213
  self.Name == other_worksheet.Name
227
214
  end
228
215
 
216
+ # creates a range from a given defined name or address
217
+ # @params [Variant] defined name or address
218
+ # @return [Range] a range
219
+ def range(name_or_address, address2 = :__not_provided)
220
+ if name_or_address.respond_to?(:gsub) && address2 == :__not_provided
221
+ name = name_or_address
222
+ range = RobustExcelOle::Range.new(name_object(name).RefersToRange, self) rescue nil
223
+ end
224
+ unless range
225
+ address = name_or_address
226
+ address = [name_or_address,address2] unless address2 == :__not_provided
227
+ workbook.retain_saved do
228
+ begin
229
+ self.Names.Add('__dummy001',nil,true,nil,nil,nil,nil,nil,nil,'=' + address_tool.as_r1c1(address))
230
+ range = RobustExcelOle::Range.new(name_object('__dummy001').RefersToRange, self)
231
+ self.Names.Item('__dummy001').Delete
232
+ rescue
233
+ address2_string = address2.nil? ? "" : ", #{address2.inspect}"
234
+ raise RangeNotCreated, "cannot create range (#{name_or_address.inspect}#{address2_string})"
235
+ end
236
+ end
237
+ end
238
+ range
239
+ end
240
+
229
241
  # @private
230
242
  # returns true, if the worksheet object responds to VBA methods, false otherwise
231
243
  def alive?
@@ -258,7 +270,7 @@ module RobustExcelOle
258
270
 
259
271
  # @private
260
272
  def inspect
261
- self.to_s[0..-2] + "#{workbook.Name} " + ">"
273
+ to_s
262
274
  end
263
275
 
264
276
  include MethodHelpers
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
35
35
  s.require_paths = ["lib"]
36
36
  s.add_runtime_dependency "pry", '>= 0.12.1'
37
+ s.add_runtime_dependency "pry-bond", '>=0.01'
37
38
  s.add_development_dependency "rspec", '>= 2.6.0'
38
39
  s.required_ruby_version = '>= 2.1'
39
40
  end
@@ -41,6 +41,13 @@ describe ListObject do
41
41
  @sheet[1,1].Value.should == "Person"
42
42
  end
43
43
 
44
+ it "should do the idempotence" do
45
+ ole_table = @sheet.ListObjects.Item(1)
46
+ table = Table.new(ole_table)
47
+ table2 = Table.new(table)
48
+ table2.ole_table.should be_a WIN32OLE
49
+ end
50
+
44
51
  it "should type-lift a Win32ole list object into a RobustExcelOle list object" do
45
52
  ole_table = @sheet.ListObjects.Item(1)
46
53
  table = Table.new(ole_table)
@@ -330,8 +337,6 @@ describe ListObject do
330
337
  cells[0].Column.should == 8
331
338
  cells[1].Row.should == 9
332
339
  cells[1].Column.should == 6
333
- puts "cells[0]: #{[cells[0]]}"
334
- p "cells[0]: #{[cells[0]]}"
335
340
  end
336
341
 
337
342
  end
@@ -177,9 +177,9 @@ describe RobustExcelOle::Range do
177
177
  end
178
178
  end
179
179
 
180
- describe "#v" do
180
+ describe "#value" do
181
181
 
182
- context "v, v=" do
182
+ context "value, value=" do
183
183
 
184
184
  before do
185
185
  @sheet1 = @book.sheet(1)
@@ -207,6 +207,12 @@ describe RobustExcelOle::Range do
207
207
  @sheet1.range([1..2,3..5]).v = [[1,2,3],[4,5,6]]
208
208
  @sheet1.range([1..2,3..5]).v.should == [[1,2,3],[4,5,6]]
209
209
  end
210
+
211
+ it "should color the range" do
212
+ @sheet1.range([1..2,3..5]).set_value([[1,2,3],[4,5,6]],:color => 42)
213
+ @sheet1.range([1..2,3..5]).Interior.ColorIndex.should == 42
214
+ end
215
+
210
216
  end
211
217
  end
212
218
 
@@ -1096,6 +1096,16 @@ describe Workbook do
1096
1096
  range.Address.should == "$A$1:$D$3"
1097
1097
  end
1098
1098
 
1099
+ it "should raise error when given integer range" do
1100
+ expect{
1101
+ @book1.range([1..2,3..4])
1102
+ }.to raise_error(RangeNotCreated, /argument/)
1103
+ end
1104
+
1105
+ it "should accept an integer range when given a worksheet" do
1106
+ @book1.range(@book1.sheet(1),[4..5,1..2]).Address.should == "$A$4:$B$5"
1107
+ end
1108
+
1099
1109
  end
1100
1110
 
1101
1111
  context "adding and deleting the name of a range" do
@@ -19,6 +19,7 @@ describe Worksheet do
19
19
  before do
20
20
  @dir = create_tmpdir
21
21
  @simple_file = @dir + '/workbook.xls'
22
+ @another_workbook = @dir + '/another_workbook.xls'
22
23
  @protected_file = @dir + '/protected_sheet.xls'
23
24
  @blank_file = @dir + '/book_with_blank.xls'
24
25
  @merge_file = @dir + '/merge_cells.xls'
@@ -207,11 +208,13 @@ describe Worksheet do
207
208
  describe "range" do
208
209
 
209
210
  it "should a range with relative r1c1-reference" do
211
+ @sheet.range([1,1]).Select
210
212
  @sheet.range(["Z1S[3]:Z[2]S8"]).Address.should == "$D$1:$H$3"
211
213
  @sheet.range(["Z1S3:Z2S8"]).Address.should == "$C$1:$H$2"
212
214
  end
213
215
 
214
216
  it "should a range with relative integer-range-reference" do
217
+ @sheet.range([1,1]).Select
215
218
  @sheet.range([1..[2],[3]..8]).Address.should == "$D$1:$H$3"
216
219
  end
217
220
 
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.22.2
4
+ version: '1.23'
5
5
  platform: ruby
6
6
  authors:
7
7
  - traths
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-10 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.12.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-bond
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.01'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.01'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -117,8 +131,10 @@ files:
117
131
  - lib/robust_excel_ole.rb
118
132
  - lib/robust_excel_ole/address_tool.rb
119
133
  - lib/robust_excel_ole/base.rb
134
+ - lib/robust_excel_ole/base.rbs
120
135
  - lib/robust_excel_ole/bookstore.rb
121
136
  - lib/robust_excel_ole/cell.rb
137
+ - lib/robust_excel_ole/cell.rbs
122
138
  - lib/robust_excel_ole/cygwin.rb
123
139
  - lib/robust_excel_ole/excel.rb
124
140
  - lib/robust_excel_ole/general.rb
@@ -128,6 +144,7 @@ files:
128
144
  - lib/robust_excel_ole/robustexcelole.sublime-project
129
145
  - lib/robust_excel_ole/robustexcelole.sublime-workspace
130
146
  - lib/robust_excel_ole/vba_objects.rb
147
+ - lib/robust_excel_ole/vba_objects.rbs
131
148
  - lib/robust_excel_ole/version.rb
132
149
  - lib/robust_excel_ole/workbook.rb
133
150
  - lib/robust_excel_ole/worksheet.rb