robust_excel_ole 1.31 → 1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +20 -1
  3. data/README.rdoc +118 -18
  4. data/___dummy_workbook.xls +0 -0
  5. data/benchmarking/creek_example.rb +1 -1
  6. data/benchmarking/roo_example.rb +1 -1
  7. data/benchmarking/simple_xlsx_reader_example.rb +1 -1
  8. data/benchmarking/spreadsheet_example.rb +1 -1
  9. data/docs/README_excel.rdoc +16 -24
  10. data/docs/README_listobjects.rdoc +176 -0
  11. data/docs/README_open.rdoc +12 -12
  12. data/docs/README_ranges.rdoc +72 -55
  13. data/docs/README_save_close.rdoc +3 -3
  14. data/docs/README_sheet.rdoc +18 -13
  15. data/examples/example_ruby_library.rb +2 -2
  16. data/examples/introductory_examples/example_range.rb +2 -2
  17. data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
  18. data/examples/modifying_sheets/example_add_names.rb +1 -1
  19. data/examples/modifying_sheets/example_concating.rb +1 -1
  20. data/examples/modifying_sheets/example_copying.rb +2 -2
  21. data/examples/modifying_sheets/example_listobjects.rb +86 -0
  22. data/examples/modifying_sheets/example_naming.rb +1 -1
  23. data/examples/modifying_sheets/example_ranges.rb +1 -1
  24. data/examples/open_save_close/example_control_to_excel.rb +1 -1
  25. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
  26. data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
  27. data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
  28. data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
  29. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
  30. data/examples/open_save_close/example_read_only.rb +1 -1
  31. data/examples/open_save_close/example_simple.rb +1 -1
  32. data/examples/open_save_close/example_unobtrusively.rb +3 -3
  33. data/lib/robust_excel_ole/address_tool.rb +54 -44
  34. data/lib/robust_excel_ole/base.rb +4 -6
  35. data/lib/robust_excel_ole/bookstore.rb +2 -16
  36. data/lib/robust_excel_ole/cell.rb +16 -21
  37. data/lib/robust_excel_ole/excel.rb +131 -186
  38. data/lib/robust_excel_ole/general.rb +82 -55
  39. data/lib/robust_excel_ole/list_object.rb +182 -109
  40. data/lib/robust_excel_ole/list_row.rb +65 -38
  41. data/lib/robust_excel_ole/range.rb +125 -93
  42. data/lib/robust_excel_ole/range_owners.rb +52 -66
  43. data/lib/robust_excel_ole/version.rb +1 -1
  44. data/lib/robust_excel_ole/workbook.rb +168 -176
  45. data/lib/robust_excel_ole/worksheet.rb +177 -141
  46. data/robust_excel_ole.gemspec +4 -3
  47. data/spec/bookstore_spec.rb +2 -3
  48. data/spec/cell_spec.rb +9 -9
  49. data/spec/data/more_data/workbook.xls +0 -0
  50. data/spec/excel_spec.rb +132 -85
  51. data/spec/general_spec.rb +47 -15
  52. data/spec/list_object_spec.rb +258 -145
  53. data/spec/list_row_spec.rb +218 -0
  54. data/spec/range_spec.rb +76 -29
  55. data/spec/spec_helper.rb +15 -1
  56. data/spec/workbook_spec.rb +75 -34
  57. data/spec/workbook_specs/workbook_all_spec.rb +2 -1
  58. data/spec/workbook_specs/workbook_misc_spec.rb +20 -13
  59. data/spec/workbook_specs/workbook_open_spec.rb +47 -45
  60. data/spec/workbook_specs/workbook_save_spec.rb +21 -22
  61. data/spec/workbook_specs/workbook_sheet_spec.rb +3 -3
  62. data/spec/workbook_specs/workbook_unobtr_spec.rb +303 -303
  63. data/spec/worksheet_spec.rb +522 -318
  64. metadata +37 -2
@@ -6,7 +6,7 @@
6
6
 
7
7
  Imagine, you have opened a workbook with
8
8
 
9
- workbook = Workbook.open('spec/data/workbook.xls', :visible => true)
9
+ workbook = Workbook.open('spec/data/workbook.xls', visible: true)
10
10
 
11
11
  and have modified it.
12
12
 
@@ -33,13 +33,13 @@ If a workbook with the file name already exists, then
33
33
 
34
34
  For example, you want to save a workbook and overwrite the file if it exists before, then use
35
35
 
36
- workbook.save_as('another_workbook.xls', :if_exists => :overwrite)
36
+ workbook.save_as('another_workbook.xls', if_exists: :overwrite)
37
37
 
38
38
  If a workbook blocks the workbook that should be saved, then the former one can be saved and closed before.
39
39
 
40
40
  workbook = Workbook.open('spec/data/workbook.xls')
41
41
  workbook2 = Workbook.open('spec/data/another_workbook.xls')
42
- workbook2.save_as('dir/workbook.xls', :if_exists => :overwrite, :if_obstructed => :save)
42
+ workbook2.save_as('dir/workbook.xls', if_exists: :overwrite, if_obstructed: :save)
43
43
 
44
44
  === Closing a workbook.
45
45
 
@@ -6,7 +6,7 @@ Worksheets are represented by Worksheet objects.
6
6
 
7
7
  Assume you have opened a workbook
8
8
 
9
- workbook = Workbook.open('spec/data/workbook.xls', :visible => true)
9
+ workbook = Workbook.open('spec/data/workbook.xls', visible: true)
10
10
 
11
11
  === Accessing a worksheet.
12
12
 
@@ -53,11 +53,11 @@ You can add (append) an empty worksheet using
53
53
 
54
54
  Additionally you can name it.
55
55
 
56
- workbook.add_empty_sheet(:as => 'sheet_name')
56
+ workbook.add_empty_sheet(as: 'sheet_name')
57
57
 
58
58
  You can specify the position of the added empty worksheet.
59
59
 
60
- workbook.add_empty_sheet(:as => 'new_name', :before => another_sheet)
60
+ workbook.add_empty_sheet(as: 'new_name', before: another_sheet)
61
61
 
62
62
  You can copy a worksheet and add it.
63
63
 
@@ -65,31 +65,36 @@ You can copy a worksheet and add it.
65
65
 
66
66
  Additionally you can specify a name and a position.
67
67
 
68
- workbook.copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
68
+ workbook.copy_sheet(sheet, as: 'new_name', after: another_sheet)
69
69
 
70
70
  If you want to copy a worksheet, if a worksheet +sheet+ is given, and add an empty worksheet, if no worksheet is given, then use
71
71
 
72
72
  workbook.add_or_copy_sheet
73
73
 
74
- workbook.add_or_copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
74
+ workbook.add_or_copy_sheet(sheet, as: 'new_name', after: another_sheet)
75
75
 
76
76
  Note, that running in jruby, due to some restrictions of jruby, there is a workaround when adding or copy a worksheet at the end (appending): the last worksheet is being copied and deleted afterwards, in order to serve as a dummy worksheet. This may cause a different behaviour.
77
77
 
78
78
  === Accessing rows and columns
79
79
 
80
- The methods Worksheet#each, Worksheet#each_row and Worksheet#each_column enable to access each cell, row and column, respectively.
80
+ The methods Worksheet#each returns an enumerator traversing the rows (more specific: the row values) in the used range of the worksheet. The methods +each_row+ and +each_column traverse the values in the rows and columns, respectively, using an optional offset.
81
+ The methods +each_cell+ enables to access the values of each cell.
81
82
 
82
- worksheet.each do |cell|
83
- # do something with cell
84
- # read every row, every column
83
+ worksheet.each do |row_values|
84
+ # do something with the row_values
85
+ end
86
+
87
+ worksheet.each_row(2) do |row|
88
+ # do something with row beginning with 2nd row
85
89
  end
86
90
 
87
- worksheet.each_row do |row|
88
- # do something with row
91
+ worksheet.each_column(3) do |column|
92
+ # do something with column beginning with 3rd column
89
93
  end
90
94
 
91
- worksheet.each_column do |column|
92
- # do something with column
95
+ worksheet.each_cell do |cell|
96
+ # do something with cell
97
+ # read every row, every column
93
98
  end
94
99
 
95
100
  The method Worksheet#values yields a 2-dimensional array that contains the values in each row, e.g.
@@ -14,8 +14,8 @@ workbook.each do |worksheet|
14
14
  puts "Reading: #{worksheet.name}"
15
15
  num_rows = 0
16
16
 
17
- worksheet.each do |row|
18
- row_cells = row.map{ |cell| cell.value }
17
+ worksheet.each do |row_values|
18
+ a = row_values.map{ |cell| cell }
19
19
  num_rows += 1
20
20
 
21
21
  # uncomment to print out row values
@@ -67,12 +67,12 @@ value = book["name"]
67
67
  puts 'value of range "name": #{value}'
68
68
  # renaming a range
69
69
  puts 'renaming range from "name" to "new_name"'
70
- book.rename_range("name", "new_name")
70
+ book.rename_name("name", "new_name")
71
71
  # deleting the name of a range
72
72
  puts 'deleting name "new_name"'
73
73
  book.delete_name("new_name")
74
74
  # reading the value of a cell
75
- cell_value = sheet[1,1].Value
75
+ cell_value = sheet[1,1]
76
76
  puts "value of 1st cell: #{cell_value}"
77
77
  # writing the value of a cell
78
78
  puts 'writing the value "bar" into 1st cell'
@@ -15,22 +15,22 @@ begin
15
15
  File.delete simple_save_file rescue nil
16
16
  book = Workbook.open(simple_file, :visible => true) # open a book
17
17
  sheet = book.sheet(1) # access a sheet via integer
18
- cell = sheet[1,1] # access the first cell
18
+ cell = sheet.range([1,1]) # access the first cell
19
19
  puts "1st cell: #{cell.Value}" # put the value of the first cell
20
20
  sheet[1,1] = "complex" # write a value into a cell
21
- puts "new cell: #{sheet[1,1].Value}"
21
+ puts "new cell: #{sheet[1,1]}"
22
22
  puts "all cells:"
23
- sheet.each do |cell| # access all cells
23
+ sheet.each_cell do |cell| # access all cells
24
24
  puts "#{cell.Value}" # for each row: for every column: put the value of the cells
25
25
  end
26
26
 
27
27
  sheet_enum = proc do |enum_method| # put each cell, each row or each column
28
28
  i = 0
29
29
  sheet.send(enum_method) do |item|
30
- i = i + 1
30
+ i += 1
31
31
  item_name =
32
32
  case enum_method
33
- when :each then "cell"
33
+ when :each_cell then "cell"
34
34
  when :each_row then "row"
35
35
  when :each_column then "column"
36
36
  end
@@ -38,7 +38,7 @@ begin
38
38
  end
39
39
  end
40
40
 
41
- sheet_enum[:each] # put cells
41
+ sheet_enum[:each_cell] # put cells
42
42
  sheet_enum[:each_row] # put rows
43
43
  sheet_enum[:each_column] # put columns
44
44
 
@@ -38,7 +38,7 @@ begin
38
38
  colnr = idx+1
39
39
  puts "colnr: #{colnr}"
40
40
  sheet[1,colnr] = nam
41
- puts "sheet[1,colnr]: #{sheet[1,colnr].Value}"
41
+ puts "sheet[1,colnr]: #{sheet[1,colnr]}"
42
42
  sheet.add_name(nam,[nil,colnr])
43
43
  puts "sheet.Range().Address: #{sheet.Range(nam).Address}"
44
44
  end
@@ -20,7 +20,7 @@ begin
20
20
 
21
21
  Workbook.unobtrusively(extended_file_name) do |book|
22
22
  book.each do |sheet|
23
- sheet.each do |cell|
23
+ sheet.each_cell do |cell|
24
24
  name = cell.Name.Name rescue nil
25
25
  if name
26
26
  cell.Value = cell.Value.to_s + cell.Offset(0,1).Value.to_s
@@ -26,13 +26,13 @@ begin
26
26
  book.each do |sheet|
27
27
  new_sheet = book.add_sheet
28
28
  contains_named_cells = false
29
- sheet.each do |cell|
29
+ sheet.each_cell do |cell|
30
30
  full_name = cell.Name.Name rescue nil
31
31
  if full_name
32
32
  sheet_name, short_name = full_name.split("!")
33
33
  cell_name = short_name ? short_name : sheet_name
34
34
  contains_named_cells = true
35
- new_sheet[cell.Row, cell.Column].Value = cell.Value
35
+ new_sheet[cell.Row, cell.Column] = cell.Value
36
36
  new_sheet.add_name(cell_name, [cell.Row,cell.Column])
37
37
  end
38
38
  end
@@ -0,0 +1,86 @@
1
+ # example_ranges.rb:
2
+ # access row and column ranges of a sheet.
3
+
4
+ require_relative '../../lib/robust_excel_ole'
5
+ require_relative '../../spec/helpers/create_temporary_dir'
6
+ require "fileutils"
7
+
8
+ include RobustExcelOle
9
+
10
+ using StringRefinement
11
+
12
+ Excel.close_all
13
+ begin
14
+ dir = create_tmpdir
15
+ table_file = dir + 'workbook_listobjects.xlsx'
16
+ book = Workbook.open(table_file, :visible => true) # open a workbook
17
+ sheet = book.sheet(3) # access a worksheet via the name
18
+ table = sheet.table(1) # access a list object (table)
19
+
20
+ puts "table: #{table}"
21
+
22
+ listrow1 = table[2] # access the second list row of the table
23
+
24
+ puts "listrow1: #{listrow1}"
25
+
26
+ values1 = listrow1.values # access the values of this listrow
27
+ puts "values: #{values1}"
28
+
29
+ listrow2 = table[{"Number" => 3, "Person" => "Angel"}] # acess a list row via a given key hash
30
+
31
+ puts "listrow2: #{listrow2}"
32
+
33
+ values2 = listrow2.values
34
+ puts "values: #{values2}"
35
+
36
+ listrows3 = table[{"Number" => 3}, limit: 2] # access maximal 2 listrows matching the key
37
+
38
+ puts "listrows3: #{listrows3}"
39
+ puts "values:"
40
+ listrows3.map{|l| puts l.values}
41
+
42
+ puts "deleting the values of the second row" # deleting the contents of the second row
43
+ table.delete_row_values(2)
44
+
45
+ puts "deleting empty rows"
46
+ table.delete_empty_rows # deleting empty rows
47
+
48
+ puts "sorting table:"
49
+ table.sort("Number") # sort table
50
+
51
+ puts "find all cells:" # find all cells containing a given value
52
+ cells = table.find_cells(40)
53
+ puts "cells: #{cells}"
54
+
55
+ # create a new table
56
+ table2 = Table.new(sheet, "table_name", [20,1], 3, ["Verkäufer", "Straße", "area in m²"])
57
+ puts "table2: #{table2}"
58
+
59
+ table_row1 = table[1]
60
+ puts "list_row1 of second table: #{table_row1}"
61
+
62
+ table_row1.verkaeufer = "John"
63
+ value3 = table_row1.verkaeufer
64
+ puts "value of verkaeufer: #{value3}"
65
+
66
+ value4 = table_row1.Verkaeufer
67
+ puts "value of verkaeufer: #{value4}"
68
+
69
+ table_row1.strasse = 42
70
+ value5 = table_row1.strasse
71
+ puts "value of strasse: #{value5}"
72
+
73
+ table_row1.area_in_m2 = 400
74
+ value6 = table_row1.area_in_m2
75
+ puts "value of area in m2: #{value6}"
76
+
77
+ sleep 5
78
+
79
+ book.close(:if_unsaved => :forget)
80
+
81
+ ensure
82
+ Excel.close_all
83
+ rm_tmp(dir)
84
+ end
85
+
86
+
@@ -27,7 +27,7 @@ begin
27
27
 
28
28
  Workbook.unobtrusively(extended_file_name) do |book|
29
29
  book.each do |sheet|
30
- sheet.each do |cell_orig|
30
+ sheet.each_cell do |cell_orig|
31
31
  contents = cell_orig.Value
32
32
  sheet.add_name(contents, [cell_orig.Row, cell_orig.Column]) if contents && contents.is_a?(String)
33
33
  end
@@ -24,7 +24,7 @@ begin
24
24
 
25
25
  i = 0
26
26
  row_r.values.each do |value| # access the values of the first row
27
- i = i + 1
27
+ i += 1
28
28
  puts "cell #{i} of the range of the 1st row: #{value}"
29
29
  end
30
30
 
@@ -14,7 +14,7 @@ begin
14
14
  book = Workbook.open(file_name, :visible => true) # open a book
15
15
  sleep 1
16
16
  sheet = book.sheet(1) # access a worksheet
17
- sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
17
+ sheet[1,1] = sheet[1,1] == "simple" ? "complex" : "simple" # change a cell
18
18
  sleep 1
19
19
  begin
20
20
  new_book = Workbook.open(file_name, :visible => true, :if_unsaved => :alert) # open another workbook with the same file name
@@ -15,7 +15,7 @@ begin
15
15
  book = Workbook.open(file_name, :visible => true) # open a workbook, make Excel visible
16
16
  sleep 1
17
17
  sheet = book.sheet(1)
18
- first_cell = sheet[1,1].Value # access a worksheet
18
+ first_cell = sheet[1,1] # access a worksheet
19
19
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
20
20
  sleep 1
21
21
  begin
@@ -15,7 +15,7 @@ begin
15
15
  book = Workbook.open(file_name, :visible => true) # open a workbook, make Excel visible
16
16
  sleep 1
17
17
  sheet = book.sheet(1)
18
- first_cell = sheet[1,1].Value # access a worksheet
18
+ first_cell = sheet[1,1] # access a worksheet
19
19
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
20
20
  sleep 1
21
21
  new_book = Workbook.open(other_file_name, :if_obstructed => :save) # open a workbook with the same file name in a different path
@@ -23,11 +23,11 @@ begin
23
23
  old_book = Workbook.open(file_name, :if_obstructed => :forget ,:visible => true) # open the old book
24
24
  sleep 1
25
25
  old_sheet = old_book.sheet(1)
26
- old_first_cell = old_sheet[1,1].Value
26
+ old_first_cell = old_sheet[1,1]
27
27
  puts "the old book was saved" unless old_first_cell == first_cell
28
28
  new_book.close # close the workbooks
29
29
  old_book.close
30
30
  ensure
31
31
  Excel.kill_all # close all workbooks, quit Excel application
32
- rm_tmp(dir)
32
+ #rm_tmp(dir)
33
33
  end
@@ -13,7 +13,7 @@ begin
13
13
  file_name = dir + 'workbook.xls'
14
14
  book = Workbook.open(file_name, :visible => true) # open a workbook
15
15
  sheet = book.sheet(1) # access a worksheet
16
- sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
16
+ sheet[1,1] = sheet[1,1] == "simple" ? "complex" : "simple" # change a cell
17
17
  begin
18
18
  new_book = Workbook.open(file_name) # open another workbook with the same file name
19
19
  rescue WorkbookNotSaved => msg # by default: raises an exception:
@@ -15,7 +15,7 @@ begin
15
15
  puts "file_name: #{file_name}"
16
16
  sleep 1
17
17
  sheet = book.sheet(1) # access a worksheet
18
- first_cell = sheet[1,1].Value
18
+ first_cell = sheet[1,1]
19
19
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
20
20
  sleep 1
21
21
  puts "new_book: before"
@@ -24,11 +24,11 @@ begin
24
24
  # and close the unsaved workbook without saving it
25
25
  puts "new_book: after"
26
26
  sheet_new_book = new_book.sheet(1)
27
- if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].Value == first_cell then # check whether the unsaved workbook
27
+ if (not book.alive?) && new_book.alive? && sheet_new_book[1,1] == first_cell then # check whether the unsaved workbook
28
28
  puts "open with :if_unsaved => :forget : the unsaved book is closed and not saved." # is closed and was not saved
29
29
  end
30
30
  sleep 1
31
- sheet_new_book[1,1] = sheet_new_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
31
+ sheet_new_book[1,1] = sheet_new_book[1,1] == "simple" ? "complex" : "simple" # change a cell
32
32
  # open another workbook in a new Excel application, and make Excel visible, leaving the unsaved workbook open
33
33
  another_book = Workbook.open(file_name, :if_unsaved => :new_excel, :visible => true)
34
34
  sleep 3 # leaving the unsaved workbook open
@@ -13,21 +13,21 @@ begin
13
13
  file_name = dir + 'workbook.xls'
14
14
  book = Workbook.open(file_name, :visible => true) # open a workbook
15
15
  sheet = book.sheet(1) # access a worksheet
16
- first_cell = sheet[1,1].Value
16
+ first_cell = sheet[1,1]
17
17
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
18
18
  sleep 1
19
19
  new_book = Workbook.open(file_name, :if_unsaved => :new_excel, :visible => true) # open another workbook with the same file name in a new Excel
20
20
  sheet_new_book = new_book.sheet(1)
21
- if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].Value == first_cell then # check whether the unsaved workbook
21
+ if (not book.alive?) && new_book.alive? && sheet_new_book[1,1] == first_cell then # check whether the unsaved workbook
22
22
  puts "open with :if_unsaved => :forget : the unsaved book is closed and not saved." # is closed and was not saved
23
23
  end
24
24
  sleep 1
25
- sheet_new_book[1,1] = sheet_new_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
25
+ sheet_new_book[1,1] = sheet_new_book[1,1] == "simple" ? "complex" : "simple" # change a cell
26
26
  # open another workbook in the running Excel application, and make Excel visible, closing the unsaved workbook
27
27
  another_book = Workbook.open(file_name, :if_unsaved => :forget, :visible => true)
28
28
  sleep 1
29
29
  sheet_another_book = another_book.sheet(1)
30
- sheet_another_book[1,1] = sheet_another_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
30
+ sheet_another_book[1,1] = sheet_another_book[1,1] == "simple" ? "complex" : "simple" # change a cell
31
31
  another_book.close(:if_unsaved => :forget ) # close the last workbook without saving it.
32
32
  book.close(:if_unsaved => :save) # close the first workbook and save it before
33
33
  ensure
@@ -14,7 +14,7 @@ begin
14
14
  book = Workbook.open(file_name, :read_only => true, :visible => true) # open a workbook with read_only and make Excel visible
15
15
  sheet = book.sheet(1) # access a worksheet
16
16
  sleep 1
17
- sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
17
+ sheet[1,1] = sheet[1,1] == "simple" ? "complex" : "simple" # change a cell
18
18
  sleep 1
19
19
  begin
20
20
  book.save # simple save.
@@ -20,7 +20,7 @@ begin
20
20
  book.excel.visible = true # make current Excel visible
21
21
  sheet = book.sheet(1) # access a worksheet
22
22
  sleep 1
23
- sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
23
+ sheet[1,1] = sheet[1,1] == "simple" ? "complex" : "simple" # change a cell
24
24
  sleep 1
25
25
  book.save # simple save
26
26
  begin
@@ -12,14 +12,14 @@ begin
12
12
  simple_file = dir + 'workbook.xls'
13
13
  book = Workbook.open(simple_file, :visible => true) # open a workbook, make Excel visible
14
14
  old_sheet = book.sheet(1)
15
- p "1st cell: #{old_sheet[1,1].Value}"
15
+ p "1st cell: #{old_sheet[1,1]}"
16
16
  sleep 2
17
17
  Workbook.unobtrusively(simple_file) do |book| # modify the book and keep its status unchanged
18
18
  sheet = book.sheet(1)
19
- sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple"
19
+ sheet[1,1] = sheet[1,1] == "simple" ? "complex" : "simple"
20
20
  end
21
21
  new_sheet = book.sheet(1)
22
- p "1st cell: #{new_sheet[1,1].Value}"
22
+ p "1st cell: #{new_sheet[1,1]}"
23
23
  p "book saved" if book.Saved
24
24
  book.close # close the workbook
25
25
  ensure