robust_excel_ole 1.26 → 1.31
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 +17 -0
- data/README.rdoc +12 -5
- data/benchmarking/reo_example.rb +1 -1
- data/benchmarking/reo_example1.rb +1 -1
- data/benchmarking/reo_example2.rb +1 -1
- data/bin/jreo +20 -1
- data/bin/reo +20 -1
- data/docs/README_open.rdoc +8 -4
- data/docs/README_sheet.rdoc +1 -7
- data/examples/introductory_examples/example_open.rb +11 -0
- data/lib/robust_excel_ole.rb +19 -16
- data/lib/robust_excel_ole/base.rb +5 -0
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +1 -1
- data/lib/robust_excel_ole/cygwin.rb +2 -0
- data/lib/robust_excel_ole/excel.rb +12 -22
- data/lib/robust_excel_ole/general.rb +270 -206
- data/lib/robust_excel_ole/list_object.rb +18 -115
- data/lib/robust_excel_ole/list_row.rb +128 -0
- data/lib/robust_excel_ole/range.rb +5 -1
- data/lib/robust_excel_ole/range_owners.rb +4 -71
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +71 -29
- data/lib/robust_excel_ole/worksheet.rb +107 -22
- data/lib/spec_helper.rb +1 -1
- data/spec/address_tool_spec.rb +2 -2
- data/spec/base_spec.rb +19 -17
- data/spec/bookstore_spec.rb +1 -1
- data/spec/cell_spec.rb +1 -1
- data/spec/cygwin_spec.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +1 -1
- data/spec/general_spec.rb +64 -7
- data/spec/list_object_spec.rb +85 -20
- data/spec/range_spec.rb +1 -14
- data/spec/spec_helper.rb +1 -1
- data/spec/workbook_spec.rb +12 -12
- data/spec/workbook_specs/workbook_all_spec.rb +8 -28
- data/spec/workbook_specs/workbook_close_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +33 -33
- data/spec/workbook_specs/workbook_open_spec.rb +56 -5
- data/spec/workbook_specs/workbook_save_spec.rb +1 -1
- data/spec/workbook_specs/workbook_sheet_spec.rb +1 -1
- data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
- data/spec/workbook_specs/workbook_unobtr_spec.rb +273 -115
- data/spec/worksheet_spec.rb +51 -19
- metadata +3 -5
- data/jreo.bat +0 -3
- data/lib/reo_console.rb +0 -68
- data/reo.bat +0 -3
data/spec/worksheet_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'spec_helper'
|
4
4
|
|
5
5
|
$VERBOSE = nil
|
6
6
|
|
@@ -23,6 +23,7 @@ describe Worksheet do
|
|
23
23
|
@protected_file = @dir + '/protected_sheet.xls'
|
24
24
|
@blank_file = @dir + '/book_with_blank.xls'
|
25
25
|
@merge_file = @dir + '/merge_cells.xls'
|
26
|
+
@listobject_file = @dir + '/workbook_listobjects.xlsx'
|
26
27
|
@book = Workbook.open(@simple_file)
|
27
28
|
@sheet = @book.sheet(1)
|
28
29
|
end
|
@@ -255,6 +256,37 @@ describe Worksheet do
|
|
255
256
|
|
256
257
|
end
|
257
258
|
|
259
|
+
describe "table" do
|
260
|
+
|
261
|
+
before do
|
262
|
+
@book = Workbook.open(@listobject_file, :visible => true)
|
263
|
+
@sheet = @book.sheet(3)
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should yield table given number" do
|
267
|
+
table = @sheet.table(1)
|
268
|
+
table.Name.should == "table3"
|
269
|
+
table.HeaderRowRange.Value.first.should == ["Number","Person","Amount","Time","Price"]
|
270
|
+
table.ListRows.Count.should == 6
|
271
|
+
@sheet[3,4].Value.should == "Number"
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should yield table given name" do
|
275
|
+
table = @sheet.table("table3")
|
276
|
+
table.Name.should == "table3"
|
277
|
+
table.HeaderRowRange.Value.first.should == ["Number","Person","Amount","Time","Price"]
|
278
|
+
table.ListRows.Count.should == 6
|
279
|
+
@sheet[3,4].Value.should == "Number"
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should raise error" do
|
283
|
+
expect{
|
284
|
+
@sheet.table("table4")
|
285
|
+
}.to raise_error(WorksheetREOError)
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
258
290
|
describe '#each' do
|
259
291
|
it "should sort line in order of column" do
|
260
292
|
@sheet.each_with_index do |cell, i|
|
@@ -613,7 +645,7 @@ describe Worksheet do
|
|
613
645
|
end
|
614
646
|
end
|
615
647
|
|
616
|
-
describe "
|
648
|
+
describe "namevalue_global, set_namevalue_global" do
|
617
649
|
|
618
650
|
before do
|
619
651
|
@book1 = Workbook.open(@dir + '/another_workbook.xls')
|
@@ -625,54 +657,54 @@ describe Worksheet do
|
|
625
657
|
end
|
626
658
|
|
627
659
|
it "should return value of a defined name" do
|
628
|
-
@sheet1.
|
660
|
+
@sheet1.namevalue_global("firstcell").should == "foo"
|
629
661
|
end
|
630
662
|
|
631
663
|
#it "should evaluate a formula" do
|
632
|
-
# @sheet1.
|
664
|
+
# @sheet1.namevalue_global("another_formula").should == 5
|
633
665
|
#end
|
634
666
|
|
635
667
|
it "should raise an error if name not defined" do
|
636
668
|
expect {
|
637
|
-
@sheet1.
|
669
|
+
@sheet1.namevalue_global("foo")
|
638
670
|
}.to raise_error(NameNotFound, /name "foo" not in/)
|
639
671
|
end
|
640
672
|
|
641
673
|
it "should raise an error of coordinates are given instead of a defined name" do
|
642
674
|
expect {
|
643
|
-
@sheet1.
|
675
|
+
@sheet1.namevalue_global("A1")
|
644
676
|
}.to raise_error(NameNotFound, /name "A1" not in/)
|
645
677
|
end
|
646
678
|
|
647
679
|
it "should return default value for a range with empty contents" do
|
648
|
-
@sheet1.
|
680
|
+
@sheet1.namevalue_global("another", :default => 2) == 2
|
649
681
|
end
|
650
682
|
|
651
683
|
it "should set a range to a value" do
|
652
|
-
@sheet1.
|
684
|
+
@sheet1.namevalue_global("firstcell").should == "foo"
|
653
685
|
@sheet1[1,1].Value.should == "foo"
|
654
|
-
@sheet1.
|
655
|
-
@sheet1.
|
686
|
+
@sheet1.set_namevalue_global("firstcell","bar")
|
687
|
+
@sheet1.namevalue_global("firstcell").should == "bar"
|
656
688
|
@sheet1[1,1].Value.should == "bar"
|
657
689
|
end
|
658
690
|
|
659
691
|
it "should raise an error if name cannot be evaluated" do
|
660
692
|
expect{
|
661
|
-
@sheet1.
|
693
|
+
@sheet1.set_namevalue_global("foo", 1)
|
662
694
|
}.to raise_error(RangeNotEvaluatable, /cannot assign value/)
|
663
695
|
end
|
664
696
|
|
665
697
|
it "should color the cell (deprecated)" do
|
666
|
-
@sheet1.
|
698
|
+
@sheet1.set_namevalue_global("new", "bar")
|
667
699
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == -4142
|
668
|
-
@sheet1.
|
700
|
+
@sheet1.set_namevalue_global("new", "bar", :color => 4)
|
669
701
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
670
702
|
end
|
671
703
|
|
672
704
|
it "should color the cell" do
|
673
|
-
@sheet1.
|
705
|
+
@sheet1.set_namevalue_global("new", "bar")
|
674
706
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == -4142
|
675
|
-
@sheet1.
|
707
|
+
@sheet1.set_namevalue_global("new", "bar", :color => 4)
|
676
708
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
677
709
|
end
|
678
710
|
|
@@ -735,7 +767,7 @@ describe Worksheet do
|
|
735
767
|
|
736
768
|
it "should raise an error if name cannot be evaluated" do
|
737
769
|
expect{
|
738
|
-
@sheet1.
|
770
|
+
@sheet1.set_namevalue_global("foo", 1)
|
739
771
|
}.to raise_error(RangeNotEvaluatable, /cannot assign value/)
|
740
772
|
end
|
741
773
|
|
@@ -751,7 +783,7 @@ describe Worksheet do
|
|
751
783
|
}.to raise_error(NameNotFound, /name "foo" not in #<Worksheet: Sheet1/)
|
752
784
|
@sheet1.namevalue("foo", :default => nil).should be_nil
|
753
785
|
@sheet1.namevalue("foo", :default => 1).should == 1
|
754
|
-
@sheet1.
|
786
|
+
@sheet1.namevalue_global("empty", :default => 1).should be_nil
|
755
787
|
end
|
756
788
|
|
757
789
|
it "should color the cell (depracated)" do
|
@@ -815,14 +847,14 @@ describe Worksheet do
|
|
815
847
|
it "should rename a range" do
|
816
848
|
@sheet1.add_name("foo",[1,1])
|
817
849
|
@sheet1.rename_range("foo","bar")
|
818
|
-
@sheet1.
|
850
|
+
@sheet1.namevalue_global("bar").should == "foo"
|
819
851
|
end
|
820
852
|
|
821
853
|
it "should delete a name of a range" do
|
822
854
|
@sheet1.add_name("foo",[1,1])
|
823
855
|
@sheet1.delete_name("foo")
|
824
856
|
expect{
|
825
|
-
@sheet1.
|
857
|
+
@sheet1.namevalue_global("foo")
|
826
858
|
}.to raise_error(NameNotFound, /name "foo"/)
|
827
859
|
end
|
828
860
|
|
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.31'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- traths
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 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
|
@@ -139,6 +137,7 @@ files:
|
|
139
137
|
- lib/robust_excel_ole/excel.rb
|
140
138
|
- lib/robust_excel_ole/general.rb
|
141
139
|
- lib/robust_excel_ole/list_object.rb
|
140
|
+
- lib/robust_excel_ole/list_row.rb
|
142
141
|
- lib/robust_excel_ole/range.rb
|
143
142
|
- lib/robust_excel_ole/range_owners.rb
|
144
143
|
- lib/robust_excel_ole/robustexcelole.sublime-project
|
@@ -149,7 +148,6 @@ files:
|
|
149
148
|
- lib/robust_excel_ole/workbook.rb
|
150
149
|
- lib/robust_excel_ole/worksheet.rb
|
151
150
|
- lib/spec_helper.rb
|
152
|
-
- reo.bat
|
153
151
|
- robust_excel_ole.gemspec
|
154
152
|
- spec/address_tool_spec.rb
|
155
153
|
- spec/base_spec.rb
|
data/jreo.bat
DELETED
data/lib/reo_console.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'pry'
|
2
|
-
require '../robust_excel_ole/lib/robust_excel_ole'
|
3
|
-
|
4
|
-
include REO
|
5
|
-
include General
|
6
|
-
|
7
|
-
# change the current binding such that self is the current object in the pry-instance,
|
8
|
-
# preserve the local variables
|
9
|
-
|
10
|
-
class Pry
|
11
|
-
|
12
|
-
class << self
|
13
|
-
attr_accessor :pry_instance
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.change_current_binding(current_object)
|
17
|
-
pry_instance = self.pry_instance
|
18
|
-
old_binding = pry_instance.binding_stack.pop
|
19
|
-
pry_instance.push_binding(current_object.__binding__)
|
20
|
-
exclude_vars = [:__, :_, :_dir, :_dir_, :_file, :_file_, :_in_, :_out_, :_ex, :_ex_, :pry_instance]
|
21
|
-
old_binding.local_variables.each do |var|
|
22
|
-
pry_instance.add_sticky_local(var) {old_binding.local_variable_get(var)} unless exclude_vars.include?(var)
|
23
|
-
end
|
24
|
-
self.pry_instance = pry_instance
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def push_initial_binding(target = nil)
|
29
|
-
# memorize the current pry instance
|
30
|
-
self.class.pry_instance = self
|
31
|
-
push_binding(target || Pry.toplevel_binding)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
# some pry configuration
|
37
|
-
Pry.config.windows_console_warning = false
|
38
|
-
Pry.config.color = false
|
39
|
-
Pry.config.prompt_name = "REO "
|
40
|
-
|
41
|
-
#Pry.config.history_save = true
|
42
|
-
#Pry.editor = 'notepad' # 'subl', 'vi'
|
43
|
-
|
44
|
-
prompt_proc1 = proc { |target_self, nest_level, pry|
|
45
|
-
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}> "
|
46
|
-
}
|
47
|
-
|
48
|
-
prompt_proc2 = proc { |target_self, nest_level, pry|
|
49
|
-
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self.inspect)})#{":#{nest_level}" unless nest_level.zero?}* "
|
50
|
-
}
|
51
|
-
|
52
|
-
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
53
|
-
[prompt_proc1, prompt_proc2]
|
54
|
-
else
|
55
|
-
Pry::Prompt.new(
|
56
|
-
"REO",
|
57
|
-
"The RobustExcelOle Prompt. Besides the standard information it puts the current object",
|
58
|
-
[prompt_proc1, prompt_proc2]
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
hooks = Pry::Hooks.new
|
63
|
-
|
64
|
-
hooks.add_hook :when_started, :hook12 do
|
65
|
-
puts 'REO console started'
|
66
|
-
puts
|
67
|
-
end
|
68
|
-
Pry.start(nil, hooks: hooks)
|
data/reo.bat
DELETED