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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +17 -0
  3. data/README.rdoc +12 -5
  4. data/benchmarking/reo_example.rb +1 -1
  5. data/benchmarking/reo_example1.rb +1 -1
  6. data/benchmarking/reo_example2.rb +1 -1
  7. data/bin/jreo +20 -1
  8. data/bin/reo +20 -1
  9. data/docs/README_open.rdoc +8 -4
  10. data/docs/README_sheet.rdoc +1 -7
  11. data/examples/introductory_examples/example_open.rb +11 -0
  12. data/lib/robust_excel_ole.rb +19 -16
  13. data/lib/robust_excel_ole/base.rb +5 -0
  14. data/lib/robust_excel_ole/bookstore.rb +1 -1
  15. data/lib/robust_excel_ole/cell.rb +1 -1
  16. data/lib/robust_excel_ole/cygwin.rb +2 -0
  17. data/lib/robust_excel_ole/excel.rb +12 -22
  18. data/lib/robust_excel_ole/general.rb +270 -206
  19. data/lib/robust_excel_ole/list_object.rb +18 -115
  20. data/lib/robust_excel_ole/list_row.rb +128 -0
  21. data/lib/robust_excel_ole/range.rb +5 -1
  22. data/lib/robust_excel_ole/range_owners.rb +4 -71
  23. data/lib/robust_excel_ole/version.rb +1 -1
  24. data/lib/robust_excel_ole/workbook.rb +71 -29
  25. data/lib/robust_excel_ole/worksheet.rb +107 -22
  26. data/lib/spec_helper.rb +1 -1
  27. data/spec/address_tool_spec.rb +2 -2
  28. data/spec/base_spec.rb +19 -17
  29. data/spec/bookstore_spec.rb +1 -1
  30. data/spec/cell_spec.rb +1 -1
  31. data/spec/cygwin_spec.rb +1 -1
  32. data/spec/data/more_data/workbook.xls +0 -0
  33. data/spec/excel_spec.rb +1 -1
  34. data/spec/general_spec.rb +64 -7
  35. data/spec/list_object_spec.rb +85 -20
  36. data/spec/range_spec.rb +1 -14
  37. data/spec/spec_helper.rb +1 -1
  38. data/spec/workbook_spec.rb +12 -12
  39. data/spec/workbook_specs/workbook_all_spec.rb +8 -28
  40. data/spec/workbook_specs/workbook_close_spec.rb +1 -1
  41. data/spec/workbook_specs/workbook_misc_spec.rb +33 -33
  42. data/spec/workbook_specs/workbook_open_spec.rb +56 -5
  43. data/spec/workbook_specs/workbook_save_spec.rb +1 -1
  44. data/spec/workbook_specs/workbook_sheet_spec.rb +1 -1
  45. data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
  46. data/spec/workbook_specs/workbook_unobtr_spec.rb +273 -115
  47. data/spec/worksheet_spec.rb +51 -19
  48. metadata +3 -5
  49. data/jreo.bat +0 -3
  50. data/lib/reo_console.rb +0 -68
  51. data/reo.bat +0 -3
@@ -11,6 +11,8 @@ module RobustExcelOle
11
11
  # worksheet: see https://github.com/Thomas008/robust_excel_ole/blob/master/lib/robust_excel_ole/worksheet.rb
12
12
  class Worksheet < RangeOwners
13
13
 
14
+ using ToReoRefinement
15
+
14
16
  attr_reader :ole_worksheet
15
17
  attr_reader :workbook
16
18
 
@@ -80,7 +82,7 @@ module RobustExcelOle
80
82
  else
81
83
  name = p1
82
84
  begin
83
- namevalue_glob(name)
85
+ namevalue_global(name)
84
86
  rescue REOError
85
87
  namevalue(name)
86
88
  end
@@ -96,10 +98,10 @@ module RobustExcelOle
96
98
  else
97
99
  name, value = p1, p2
98
100
  begin
99
- set_namevalue_glob(name, value)
101
+ set_namevalue_global(name, value)
100
102
  rescue REOError
101
103
  begin
102
- workbook.set_namevalue_glob(name, value)
104
+ workbook.set_namevalue_global(name, value)
103
105
  rescue REOError
104
106
  set_namevalue(name, value)
105
107
  end
@@ -107,6 +109,71 @@ module RobustExcelOle
107
109
  end
108
110
  end
109
111
 
112
+ # returns the contents of a range with a locally defined name
113
+ # evaluates the formula if the contents is a formula
114
+ # if the name could not be found or the range or value could not be determined,
115
+ # then return default value, if provided, raise error otherwise
116
+ # @param [String] name the name of a range
117
+ # @param [Hash] opts the options
118
+ # @option opts [Symbol] :default the default value that is provided if no contents could be returned
119
+ # @return [Variant] the contents of a range with given name
120
+ def namevalue(name, opts = { :default => :__not_provided })
121
+ begin
122
+ ole_range = self.Range(name)
123
+ rescue # WIN32OLERuntimeError, VBAMethodMissingError, Java::OrgRacobCom::ComFailException
124
+ return opts[:default] unless opts[:default] == :__not_provided
125
+ raise NameNotFound, "name #{name.inspect} not in #{self.inspect}"
126
+ end
127
+ begin
128
+ worksheet = self if self.is_a?(Worksheet)
129
+ #value = ole_range.Value
130
+ value = if !::RANGES_JRUBY_BUG
131
+ ole_range.Value
132
+ else
133
+ values = RobustExcelOle::Range.new(ole_range, worksheet).v
134
+ (values.size==1 && values.first.size==1) ? values.first.first : values
135
+ end
136
+ rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException
137
+ return opts[:default] unless opts[:default] == :__not_provided
138
+ raise RangeNotEvaluatable, "cannot determine value of range named #{name.inspect} in #{self.inspect}"
139
+ end
140
+ if value == -2146828288 + RobustExcelOle::XlErrName
141
+ return opts[:default] unless opts[:default] == __not_provided
142
+ raise RangeNotEvaluatable, "cannot evaluate range named #{name.inspect} in #{File.basename(workbook.stored_filename).inspect rescue nil}"
143
+ end
144
+ return opts[:default] unless (opts[:default] == :__not_provided) || value.nil?
145
+ value
146
+ end
147
+
148
+ # assigns a value to a range given a locally defined name
149
+ # @param [String] name the name of a range
150
+ # @param [Variant] value the assigned value
151
+ # @option opts [Symbol] :color the color of the cell when set
152
+ def set_namevalue(name, value, opts = { })
153
+ begin
154
+ ole_range = self.Range(name)
155
+ rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException, VBAMethodMissingError
156
+ raise NameNotFound, "name #{name.inspect} not in #{self.inspect}"
157
+ end
158
+ begin
159
+ ole_range.Interior.ColorIndex = opts[:color] unless opts[:color].nil?
160
+ if !::RANGES_JRUBY_BUG
161
+ ole_range.Value = value
162
+ else
163
+ address_r1c1 = ole_range.AddressLocal(true,true,XlR1C1)
164
+ row, col = address_tool.as_integer_ranges(address_r1c1)
165
+ row.each_with_index do |r,i|
166
+ col.each_with_index do |c,j|
167
+ ole_range.Cells(i+1,j+1).Value = (value.respond_to?(:first) ? value[i][j] : value)
168
+ end
169
+ end
170
+ end
171
+ value
172
+ rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException
173
+ raise RangeNotEvaluatable, "cannot assign value to range named #{name.inspect} in #{self.inspect}"
174
+ end
175
+ end
176
+
110
177
  # value of a cell, if row and column are given
111
178
  # @params row and column
112
179
  # @returns value of the cell
@@ -129,10 +196,12 @@ module RobustExcelOle
129
196
  raise RangeNotEvaluatable, "cannot assign value #{value.inspect} to cell (#{y.inspect},#{x.inspect})"
130
197
  end
131
198
 
199
+ # provides a 2-dimensional array that contains the values in each row
132
200
  def values
133
201
  @ole_worksheet.UsedRange.Value
134
202
  end
135
203
 
204
+ # enumerator for accessing cells
136
205
  def each
137
206
  each_row do |row_range|
138
207
  row_range.each do |cell|
@@ -151,24 +220,7 @@ module RobustExcelOle
151
220
  end
152
221
  end
153
222
 
154
- def each_rowvalue
155
- @ole_worksheet.UsedRange.Value.each do |row_values|
156
- yield row_values
157
- end
158
- end
159
-
160
- def each_value # :deprecated: #
161
- each_rowvalue
162
- end
163
-
164
- def each_rowvalue_with_index(offset = 0)
165
- i = offset
166
- @ole_worksheet.UsedRange.Value.each do |row_values|
167
- yield row_values, i
168
- i += 1
169
- end
170
- end
171
-
223
+ # enumerator for accessing rows
172
224
  def each_row(offset = 0)
173
225
  offset += 1
174
226
  1.upto(@end_row) do |row|
@@ -183,6 +235,7 @@ module RobustExcelOle
183
235
  end
184
236
  end
185
237
 
238
+ # enumerator for accessing columns
186
239
  def each_column(offset = 0)
187
240
  offset += 1
188
241
  1.upto(@end_column) do |column|
@@ -197,6 +250,24 @@ module RobustExcelOle
197
250
  end
198
251
  end
199
252
 
253
+ def each_rowvalue # :deprecated: #
254
+ values.each do |row_values|
255
+ yield row_values
256
+ end
257
+ end
258
+
259
+ def each_value # :deprecated: #
260
+ each_rowvalue
261
+ end
262
+
263
+ def each_rowvalue_with_index(offset = 0) # :deprecated: #
264
+ i = offset
265
+ values.each do |row_values|
266
+ yield row_values, i
267
+ i += 1
268
+ end
269
+ end
270
+
200
271
  def row_range(row, integer_range = nil)
201
272
  integer_range ||= 1..@end_column
202
273
  RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(row, integer_range.min), @ole_worksheet.Cells(row, integer_range.max)), self)
@@ -238,6 +309,17 @@ module RobustExcelOle
238
309
  range
239
310
  end
240
311
 
312
+ # @params [Variant] table (listobject) name or number
313
+ # @return [ListObject] a table (listobject)
314
+ def table(number_or_name)
315
+ begin
316
+ ole_listobject = @ole_worksheet.ListObjects.Item(number_or_name)
317
+ rescue
318
+ raise WorksheetREOError, "table #{number_or_name} not found"
319
+ end
320
+ ListObject.new(ole_listobject)
321
+ end
322
+
241
323
  # @private
242
324
  # returns true, if the worksheet object responds to VBA methods, false otherwise
243
325
  def alive?
@@ -248,11 +330,14 @@ module RobustExcelOle
248
330
  false
249
331
  end
250
332
 
333
+ using ParentRefinement
334
+ using StringRefinement
335
+
251
336
  # @private
252
337
  def self.workbook_class
253
338
  @workbook_class ||= begin
254
339
  module_name = self.parent_name
255
- "#{module_name}::Workbook".constantize
340
+ "#{module_name}::Workbook".constantize
256
341
  rescue NameError => e
257
342
  Workbook
258
343
  end
@@ -2,7 +2,7 @@
2
2
  require 'rspec'
3
3
  require 'tmpdir'
4
4
  require 'fileutils'
5
- require File.join(File.dirname(__FILE__), '../lib/robust_excel_ole')
5
+ require_relative '../lib/robust_excel_ole'
6
6
 
7
7
  # @private
8
8
  module RobustExcelOle::SpecHelpers
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
4
- require File.expand_path( '../../lib/robust_excel_ole/base', __FILE__)
3
+ require_relative 'spec_helper'
4
+ require_relative '../lib/robust_excel_ole/base'
5
5
 
6
6
  $VERBOSE = nil
7
7
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
4
- require File.expand_path( '../../lib/robust_excel_ole/base', __FILE__)
3
+ require_relative 'spec_helper'
4
+ require_relative '../lib/robust_excel_ole/base'
5
5
 
6
6
  $VERBOSE = nil
7
7
 
@@ -36,19 +36,6 @@ module RobustExcelOle
36
36
  rm_tmp(@dir)
37
37
  end
38
38
 
39
- describe "trace" do
40
-
41
- it "should put some number" do
42
- a = 4
43
- Base::trace "some text #{a}"
44
- end
45
-
46
- it "should put another text" do
47
- b = Workbook.open(@simple_file)
48
- Base::trace "book: #{b}"
49
- end
50
- end
51
-
52
39
  describe "own_methods" do
53
40
 
54
41
  before do
@@ -57,8 +44,8 @@ module RobustExcelOle
57
44
  ["Activate", "ActiveSheet", "Application", "Close", "FullName", "HasPassword", "Name", "Names",
58
45
  "Password", "Protect", "ProtectSharing", "ProtectStructure", "Protect", "ReadOnly", "Save",
59
46
  "SaveAs", "Saved", "Sheets", "Unprotect"]
60
- @book_methods = ["focus", "add_sheet", "alive?", "close", "filename", "namevalue", "ole_object",
61
- "ole_workbook", "reopen", "save", "save_as", "saved", "set_namevalue"]
47
+ @book_methods = ["focus", "add_sheet", "alive?", "close", "filename", "ole_object",
48
+ "ole_workbook", "reopen", "save", "save_as", "saved"]
62
49
  @ole_excel_methods =
63
50
  ["ActiveCell", "ActiveSheet", "ActiveWorkbook", "Application", "Calculate", "Cells", "Columns",
64
51
  "DisplayAlerts", "Evaluate", "Hwnd", "Name", "Names", "Quit", "Range", "Ready", "Save",
@@ -82,6 +69,21 @@ module RobustExcelOle
82
69
 
83
70
  end
84
71
 
72
+ describe "trace" do
73
+
74
+ it "should put some number" do
75
+ a = 4
76
+ Base::trace "some text #{a}"
77
+ end
78
+
79
+ it "should put another text" do
80
+ b = Workbook.open(@simple_file)
81
+ Base::trace "book: #{b}"
82
+ end
83
+ end
84
+
85
+
86
+
85
87
  describe "misc" do
86
88
 
87
89
  it "should" do
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
3
+ require_relative 'spec_helper'
4
4
 
5
5
  =begin
6
6
  RSpec.configure do |config|
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), './spec_helper')
2
+ require_relative 'spec_helper'
3
3
 
4
4
  include RobustExcelOle
5
5
  include General
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), './spec_helper')
2
+ require_relative 'spec_helper'
3
3
 
4
4
  describe "on cygwin", :if => RUBY_PLATFORM =~ /cygwin/ do
5
5
  describe ".cygpath" do
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
3
+ require_relative 'spec_helper'
4
4
 
5
5
  $VERBOSE = nil
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
3
+ require_relative 'spec_helper'
4
4
 
5
5
  $VERBOSE = nil
6
6
 
@@ -9,6 +9,9 @@ include RobustExcelOle
9
9
 
10
10
  module RobustExcelOle
11
11
 
12
+ using StringRefinement
13
+ using ToReoRefinement
14
+
12
15
  describe General do
13
16
 
14
17
  before(:all) do
@@ -31,6 +34,8 @@ module RobustExcelOle
31
34
  @simple_file_xlsx = @dir + '/workbook.xlsx'
32
35
  @network_path = "N:/data/workbook.xls"
33
36
  @hostname_share_path = "//DESKTOP-A3C5CJ6/spec/data/workbook.xls"
37
+ @network_path_downcase = "n:/data/workbook.xls"
38
+ @hostname_share_path_downcase = "//desktop-a3c5cj6/spec/data/workbook.xls"
34
39
  @simple_file_extern = "D:/data/workbook.xls"
35
40
  @hostname_share_path = "//DESKTOP-A3C5CJ6/spec/data/workbook.xls"
36
41
  end
@@ -40,6 +45,23 @@ module RobustExcelOle
40
45
  rm_tmp(@dir)
41
46
  end
42
47
 
48
+ describe "relace_umlauts, underscore" do
49
+
50
+ it "should" do
51
+ "ä".replace_umlauts.should == "ae"
52
+ end
53
+
54
+ it "should replace umlauts" do
55
+ new_word = "BeforeÄÖÜäöüßAfter".replace_umlauts
56
+ new_word.should == "BeforeAeOeUeaeoeuessAfter"
57
+ end
58
+
59
+ it "should underscore" do
60
+ "BeforeAfter".underscore.should == "before_after"
61
+ end
62
+
63
+ end
64
+
43
65
  describe "to_reo" do
44
66
 
45
67
  before do
@@ -96,6 +118,33 @@ module RobustExcelOle
96
118
 
97
119
  end
98
120
 
121
+ describe "General.init_reo_for_win32ole" do
122
+
123
+ before do
124
+ @book1 = Workbook.open(@simple_file, :visible => true)
125
+ end
126
+
127
+ it "should apply reo-methods to win32ole objects" do
128
+ ole_book1 = @book1.ole_workbook
129
+ sheet1 = ole_book1.sheet(1)
130
+ sheet1.should be_a Worksheet
131
+ sheet1.name.should == "Sheet1"
132
+ ole_sheet1 = sheet1.ole_worksheet
133
+ range1 = ole_sheet1.range([1..2,3..4])
134
+ range1.should be_a RobustExcelOle::Range
135
+ range1.value.should == [["sheet1",nil],["foobaaa",nil]]
136
+ ole_range1 = range1.ole_range
137
+ ole_range1.copy([6,6])
138
+ range2 = sheet1.range([6..7,6..7])
139
+ range2.value.should == [["sheet1",nil],["foobaaa",nil]]
140
+ excel1 = @book1.excel
141
+ ole_excel1 = excel1.ole_excel
142
+ ole_excel1.close(:if_unsaved => :forget)
143
+ Excel.kill_all
144
+ end
145
+
146
+ end
147
+
99
148
  describe "methods, own_methods, respond_to?" do
100
149
 
101
150
  before do
@@ -239,6 +288,8 @@ module RobustExcelOle
239
288
  General.canonize(@network_path).should == @network_path
240
289
  General.canonize(@simple_file).should == @simple_file
241
290
  General.canonize(@simple_file_extern).should == @simple_file_extern
291
+ General.canonize(@hostname_share_path_downcase).should == @network_path
292
+ General.canonize(@network_path_downcase).should == @network_path_downcase
242
293
  end
243
294
 
244
295
  end
@@ -249,12 +300,18 @@ module RobustExcelOle
249
300
  it "should create a path" do
250
301
  path1 = "this" / "is" / "a" / "path"
251
302
  path1.should == "this/is/a/path"
252
- path2 = "this" / "is" / "a" / "path" /
253
- #path2.should == "this/is/a/path/"
254
- path3 = "this" /
255
- #path3.should == "this/"
256
- path4 = "this" / nil
257
- path4.should == "this"
303
+ path2 = "this" / nil
304
+ path2.should == "this"
305
+ path3 = "N:/E2" / "C:/gim/E2/workbook.xls"
306
+ path3.should == "C:/gim/E2/workbook.xls"
307
+ path4 = "N:/E2/" / "/gim/E2/workbook.xls"
308
+ path4.should == "/gim/E2/workbook.xls"
309
+ path5 = "N:/E2/" / "gim/E2/workbook.xls"
310
+ path5.should == "N:/E2/gim/E2/workbook.xls"
311
+ path6 = "N:/E2" / "spec/data/workbook.xls"
312
+ path6.should == "N:/E2/spec/data/workbook.xls"
313
+ path7 = "N:/E2" / "c:/gim/E2/workbook.xls"
314
+ path7.should == "c:/gim/E2/workbook.xls"
258
315
  end
259
316
  end
260
317
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './spec_helper')
3
+ require_relative 'spec_helper'
4
4
 
5
5
  $VERBOSE = nil
6
6
 
@@ -107,28 +107,93 @@ describe ListObject do
107
107
 
108
108
  describe "getting and setting values" do
109
109
 
110
- context "with new table" do
110
+ context "with various column names" do
111
+
112
+ context "with standard" do
113
+
114
+ before do
115
+ @table = Table.new(@sheet, "table_name", [12,1], 3, ["Person1","Win/Sales", "xiq-Xs", "OrderID", "YEAR", "length in m", "Amo%untSal___es"])
116
+ @table_row1 = @table[1]
117
+ end
118
+
119
+ it "should read and set values via alternative column names" do
120
+ @table_row1.person1.should be nil
121
+ @table_row1.person1 = "John"
122
+ @table_row1.person1.should == "John"
123
+ @sheet[13,1].Value.should == "John"
124
+ @table_row1.Person1 = "Herbert"
125
+ @table_row1.Person1.should == "Herbert"
126
+ @sheet[13,1].Value.should == "Herbert"
127
+ @table_row1.win_sales.should be nil
128
+ @table_row1.win_sales = 42
129
+ @table_row1.win_sales.should == 42
130
+ @sheet[13,2].Value.should == 42
131
+ @table_row1.Win_Sales = 80
132
+ @table_row1.Win_Sales.should == 80
133
+ @sheet[13,2].Value.should == 80
134
+ @table_row1.xiq_xs.should == nil
135
+ @table_row1.xiq_xs = 90
136
+ @table_row1.xiq_xs.should == 90
137
+ @sheet[13,3].Value.should == 90
138
+ @table_row1.xiq_Xs = 100
139
+ @table_row1.xiq_Xs.should == 100
140
+ @sheet[13,3].Value.should == 100
141
+ @table_row1.order_id.should == nil
142
+ @table_row1.order_id = 1
143
+ @table_row1.order_id.should == 1
144
+ @sheet[13,4].Value.should == 1
145
+ @table_row1.OrderID = 2
146
+ @table_row1.OrderID.should == 2
147
+ @sheet[13,4].Value.should == 2
148
+ @table_row1.year = 1984
149
+ @table_row1.year.should == 1984
150
+ @sheet[13,5].Value.should == 1984
151
+ @table_row1.YEAR = 2020
152
+ @table_row1.YEAR.should == 2020
153
+ @sheet[13,5].Value.should == 2020
154
+ @table_row1.length_in_m.should == nil
155
+ @table_row1.length_in_m = 20
156
+ @table_row1.length_in_m.should == 20
157
+ @sheet[13,6].Value.should == 20
158
+ @table_row1.length_in_m = 40
159
+ @table_row1.length_in_m.should == 40
160
+ @sheet[13,6].Value.should == 40
161
+ @table_row1.amo_unt_sal___es.should == nil
162
+ @table_row1.amo_unt_sal___es = 80
163
+ @table_row1.amo_unt_sal___es.should == 80
164
+ @sheet[13,7].Value.should == 80
165
+ end
111
166
 
112
- before do
113
- @table = Table.new(@sheet, "table_name", [1,1], 3, ["Person","Amo%untSales"])
114
- @table_row1 = @table[1]
115
167
  end
116
168
 
117
- it "should read and set values via alternative column names" do
118
- @table_row1.person.should be nil
119
- @table_row1.person = "John"
120
- @table_row1.person.should == "John"
121
- @sheet[2,1].Value.should == "John"
122
- @table_row1.amount_sales.should be nil
123
- @table_row1.amount_sales = 42
124
- @table_row1.amount_sales.should == 42
125
- @sheet[2,2].Value.should == 42
126
- @table_row1.Person = "Herbert"
127
- @table_row1.Person.should == "Herbert"
128
- @sheet[2,1].Value.should == "Herbert"
129
- @table_row1.AmountSales = 80
130
- @table_row1.AmountSales.should == 80
131
- @sheet[2,2].Value.should == 80
169
+ context "with umlauts" do
170
+
171
+ before do
172
+ @table = Table.new(@sheet, "table_name", [1,1], 3, ["Verkäufer", "Straße", "area in m²"])
173
+ @table_row1 = @table[1]
174
+ end
175
+
176
+ it "should read and set values via alternative column names" do
177
+ @table_row1.verkaeufer.should be nil
178
+ @table_row1.verkaeufer = "John"
179
+ @table_row1.verkaeufer.should == "John"
180
+ @sheet[2,1].Value.should == "John"
181
+ @table_row1.Verkaeufer = "Herbert"
182
+ @table_row1.Verkaeufer.should == "Herbert"
183
+ @sheet[2,1].Value.should == "Herbert"
184
+ @table_row1.strasse.should be nil
185
+ @table_row1.strasse = 42
186
+ @table_row1.strasse.should == 42
187
+ @sheet[2,2].Value.should == 42
188
+ @table_row1.Strasse = 80
189
+ @table_row1.Strasse.should == 80
190
+ @sheet[2,2].Value.should == 80
191
+ @table_row1.area_in_m3.should be nil
192
+ @table_row1.area_in_m3 = 10
193
+ @table_row1.area_in_m3.should == 10
194
+ @sheet[2,3].Value.should == 10
195
+ end
196
+
132
197
  end
133
198
 
134
199
  end