rubyfromexcel 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/examples/checkpoints/checkpoint/checkpoint0.marshal +0 -0
  2. data/examples/checkpoints/checkpoint/checkpoint1.marshal +0 -0
  3. data/examples/checkpoints/checkpoint/checkpoint2.marshal +0 -0
  4. data/examples/checkpoints/checkpoint/checkpoint3.marshal +0 -0
  5. data/examples/checkpoints/checkpoint/checkpoint4.marshal +0 -0
  6. data/examples/checkpoints/checkpoint/checkpoint5.marshal +0 -0
  7. data/examples/ruby-versions/array-formulas-ruby/sheets/sheet1.rb +59 -0
  8. data/examples/ruby-versions/array-formulas-ruby/sheets/sheet2.rb +9 -0
  9. data/examples/ruby-versions/array-formulas-ruby/specs/sheet1_rspec.rb +156 -0
  10. data/examples/ruby-versions/array-formulas-ruby/specs/sheet2_rspec.rb +8 -0
  11. data/examples/ruby-versions/array-formulas-ruby/spreadsheet.rb +9 -0
  12. data/examples/ruby-versions/checkpoint-ruby/sheets/sheet1.rb +307 -0
  13. data/examples/ruby-versions/checkpoint-ruby/sheets/sheet2.rb +148 -0
  14. data/examples/ruby-versions/checkpoint-ruby/specs/sheet1_rspec.rb +884 -0
  15. data/examples/ruby-versions/checkpoint-ruby/specs/sheet2_rspec.rb +412 -0
  16. data/examples/ruby-versions/checkpoint-ruby/spreadsheet.rb +9 -0
  17. data/examples/ruby-versions/complex-test-ruby/sheets/sheet1.rb +305 -0
  18. data/examples/ruby-versions/complex-test-ruby/sheets/sheet2.rb +147 -0
  19. data/examples/ruby-versions/complex-test-ruby/specs/sheet1_rspec.rb +876 -0
  20. data/examples/ruby-versions/complex-test-ruby/specs/sheet2_rspec.rb +412 -0
  21. data/examples/ruby-versions/complex-test-ruby/spreadsheet.rb +9 -0
  22. data/examples/ruby-versions/namedReferenceTest-ruby/sheets/sheet1.rb +9 -0
  23. data/examples/ruby-versions/namedReferenceTest-ruby/sheets/sheet2.rb +8 -0
  24. data/examples/ruby-versions/namedReferenceTest-ruby/specs/sheet1_rspec.rb +16 -0
  25. data/examples/ruby-versions/namedReferenceTest-ruby/specs/sheet2_rspec.rb +16 -0
  26. data/examples/ruby-versions/namedReferenceTest-ruby/spreadsheet.rb +9 -0
  27. data/examples/ruby-versions/pruning-ruby/sheets/sheet1.rb +18 -0
  28. data/examples/ruby-versions/pruning-ruby/sheets/sheet2.rb +16 -0
  29. data/examples/ruby-versions/pruning-ruby/sheets/sheet3.rb +7 -0
  30. data/examples/ruby-versions/pruning-ruby/specs/sheet1_rspec.rb +28 -0
  31. data/examples/ruby-versions/pruning-ruby/specs/sheet2_rspec.rb +28 -0
  32. data/examples/ruby-versions/pruning-ruby/specs/sheet3_rspec.rb +8 -0
  33. data/examples/ruby-versions/pruning-ruby/spreadsheet.rb +9 -0
  34. data/examples/ruby-versions/sharedFormulaTest-ruby/sheets/sheet1.rb +15 -0
  35. data/examples/ruby-versions/sharedFormulaTest-ruby/specs/sheet1_rspec.rb +44 -0
  36. data/examples/ruby-versions/sharedFormulaTest-ruby/spreadsheet.rb +9 -0
  37. data/examples/ruby-versions/table-test-ruby/sheets/sheet1.rb +17 -0
  38. data/examples/ruby-versions/table-test-ruby/sheets/sheet2.rb +5 -0
  39. data/examples/ruby-versions/table-test-ruby/sheets/sheet3.rb +5 -0
  40. data/examples/ruby-versions/table-test-ruby/specs/sheet1_rspec.rb +20 -0
  41. data/examples/ruby-versions/table-test-ruby/specs/sheet2_rspec.rb +8 -0
  42. data/examples/ruby-versions/table-test-ruby/specs/sheet3_rspec.rb +8 -0
  43. data/examples/ruby-versions/table-test-ruby/spreadsheet.rb +9 -0
  44. data/examples/sheets/2050Model.xlsx +0 -0
  45. data/examples/unzipped-sheets/array-formulas/[Content_Types].xml +2 -0
  46. data/examples/unzipped-sheets/array-formulas/docProps/app.xml +2 -0
  47. data/examples/unzipped-sheets/array-formulas/docProps/core.xml +2 -0
  48. data/examples/unzipped-sheets/array-formulas/docProps/thumbnail.jpeg +0 -0
  49. data/examples/unzipped-sheets/array-formulas/xl/_rels/workbook.xml.rels +2 -0
  50. data/examples/unzipped-sheets/array-formulas/xl/calcChain.xml +2 -0
  51. data/examples/unzipped-sheets/array-formulas/xl/sharedStrings.xml +2 -0
  52. data/examples/unzipped-sheets/array-formulas/xl/styles.xml +2 -0
  53. data/examples/unzipped-sheets/array-formulas/xl/theme/theme1.xml +2 -0
  54. data/examples/unzipped-sheets/array-formulas/xl/workbook.xml +2 -0
  55. data/examples/unzipped-sheets/array-formulas/xl/worksheets/sheet1.xml +2 -0
  56. data/examples/unzipped-sheets/array-formulas/xl/worksheets/sheet2.xml +2 -0
  57. data/examples/unzipped-sheets/checkpoint/[Content_Types].xml +2 -0
  58. data/examples/unzipped-sheets/checkpoint/docProps/app.xml +2 -0
  59. data/examples/unzipped-sheets/checkpoint/docProps/core.xml +2 -0
  60. data/examples/unzipped-sheets/checkpoint/xl/_rels/workbook.xml.rels +2 -0
  61. data/examples/unzipped-sheets/checkpoint/xl/calcChain.xml +2 -0
  62. data/examples/unzipped-sheets/checkpoint/xl/charts/chart1.xml +2 -0
  63. data/examples/unzipped-sheets/checkpoint/xl/charts/chart2.xml +2 -0
  64. data/examples/unzipped-sheets/checkpoint/xl/comments1.xml +5 -0
  65. data/examples/unzipped-sheets/checkpoint/xl/comments2.xml +5 -0
  66. data/examples/unzipped-sheets/checkpoint/xl/drawings/_rels/drawing1.xml.rels +2 -0
  67. data/examples/unzipped-sheets/checkpoint/xl/drawings/_rels/drawing2.xml.rels +2 -0
  68. data/examples/unzipped-sheets/checkpoint/xl/drawings/drawing1.xml +2 -0
  69. data/examples/unzipped-sheets/checkpoint/xl/drawings/drawing2.xml +2 -0
  70. data/examples/unzipped-sheets/checkpoint/xl/drawings/vmlDrawing1.vml +47 -0
  71. data/examples/unzipped-sheets/checkpoint/xl/drawings/vmlDrawing2.vml +47 -0
  72. data/examples/unzipped-sheets/checkpoint/xl/sharedStrings.xml +2 -0
  73. data/examples/unzipped-sheets/checkpoint/xl/styles.xml +2 -0
  74. data/examples/unzipped-sheets/checkpoint/xl/theme/theme1.xml +2 -0
  75. data/examples/unzipped-sheets/checkpoint/xl/workbook.xml +2 -0
  76. data/examples/unzipped-sheets/checkpoint/xl/worksheets/_rels/sheet1.xml.rels +2 -0
  77. data/examples/unzipped-sheets/checkpoint/xl/worksheets/_rels/sheet2.xml.rels +2 -0
  78. data/examples/unzipped-sheets/checkpoint/xl/worksheets/sheet1.xml +2 -0
  79. data/examples/unzipped-sheets/checkpoint/xl/worksheets/sheet2.xml +2 -0
  80. data/examples/unzipped-sheets/complex-test/[Content_Types].xml +2 -0
  81. data/examples/unzipped-sheets/complex-test/docProps/app.xml +2 -0
  82. data/examples/unzipped-sheets/complex-test/docProps/core.xml +2 -0
  83. data/examples/unzipped-sheets/complex-test/xl/_rels/workbook.xml.rels +2 -0
  84. data/examples/unzipped-sheets/complex-test/xl/calcChain.xml +2 -0
  85. data/examples/unzipped-sheets/complex-test/xl/charts/chart1.xml +2 -0
  86. data/examples/unzipped-sheets/complex-test/xl/charts/chart2.xml +2 -0
  87. data/examples/unzipped-sheets/complex-test/xl/comments1.xml +5 -0
  88. data/examples/unzipped-sheets/complex-test/xl/comments2.xml +5 -0
  89. data/examples/unzipped-sheets/complex-test/xl/drawings/_rels/drawing1.xml.rels +2 -0
  90. data/examples/unzipped-sheets/complex-test/xl/drawings/_rels/drawing2.xml.rels +2 -0
  91. data/examples/unzipped-sheets/complex-test/xl/drawings/drawing1.xml +2 -0
  92. data/examples/unzipped-sheets/complex-test/xl/drawings/drawing2.xml +2 -0
  93. data/examples/unzipped-sheets/complex-test/xl/drawings/vmlDrawing1.vml +46 -0
  94. data/examples/unzipped-sheets/complex-test/xl/drawings/vmlDrawing2.vml +46 -0
  95. data/examples/unzipped-sheets/complex-test/xl/sharedStrings.xml +2 -0
  96. data/examples/unzipped-sheets/complex-test/xl/styles.xml +2 -0
  97. data/examples/unzipped-sheets/complex-test/xl/theme/theme1.xml +2 -0
  98. data/examples/unzipped-sheets/complex-test/xl/workbook.xml +2 -0
  99. data/examples/unzipped-sheets/complex-test/xl/worksheets/_rels/sheet1.xml.rels +2 -0
  100. data/examples/unzipped-sheets/complex-test/xl/worksheets/_rels/sheet2.xml.rels +2 -0
  101. data/examples/unzipped-sheets/complex-test/xl/worksheets/sheet1.xml +2 -0
  102. data/examples/unzipped-sheets/complex-test/xl/worksheets/sheet2.xml +2 -0
  103. data/examples/unzipped-sheets/complex-test/xl/worksheets/sheet3.xml +2 -0
  104. data/examples/unzipped-sheets/namedReferenceTest/[Content_Types].xml +2 -0
  105. data/examples/unzipped-sheets/namedReferenceTest/docProps/app.xml +2 -0
  106. data/examples/unzipped-sheets/namedReferenceTest/docProps/core.xml +2 -0
  107. data/examples/unzipped-sheets/namedReferenceTest/docProps/thumbnail.jpeg +0 -0
  108. data/examples/unzipped-sheets/namedReferenceTest/xl/_rels/workbook.xml.rels +2 -0
  109. data/examples/unzipped-sheets/namedReferenceTest/xl/calcChain.xml +2 -0
  110. data/examples/unzipped-sheets/namedReferenceTest/xl/styles.xml +2 -0
  111. data/examples/unzipped-sheets/namedReferenceTest/xl/theme/theme1.xml +2 -0
  112. data/examples/unzipped-sheets/namedReferenceTest/xl/workbook.xml +2 -0
  113. data/examples/unzipped-sheets/namedReferenceTest/xl/worksheets/sheet1.xml +2 -0
  114. data/examples/unzipped-sheets/namedReferenceTest/xl/worksheets/sheet2.xml +2 -0
  115. data/examples/unzipped-sheets/pruning/[Content_Types].xml +2 -0
  116. data/examples/unzipped-sheets/pruning/docProps/app.xml +2 -0
  117. data/examples/unzipped-sheets/pruning/docProps/core.xml +2 -0
  118. data/examples/unzipped-sheets/pruning/docProps/thumbnail.jpeg +0 -0
  119. data/examples/unzipped-sheets/pruning/xl/_rels/workbook.xml.rels +2 -0
  120. data/examples/unzipped-sheets/pruning/xl/calcChain.xml +2 -0
  121. data/examples/unzipped-sheets/pruning/xl/sharedStrings.xml +2 -0
  122. data/examples/unzipped-sheets/pruning/xl/styles.xml +2 -0
  123. data/examples/unzipped-sheets/pruning/xl/tables/table1.xml +2 -0
  124. data/examples/unzipped-sheets/pruning/xl/theme/theme1.xml +2 -0
  125. data/examples/unzipped-sheets/pruning/xl/workbook.xml +2 -0
  126. data/examples/unzipped-sheets/pruning/xl/worksheets/_rels/sheet2.xml.rels +2 -0
  127. data/examples/unzipped-sheets/pruning/xl/worksheets/sheet1.xml +2 -0
  128. data/examples/unzipped-sheets/pruning/xl/worksheets/sheet2.xml +2 -0
  129. data/examples/unzipped-sheets/pruning/xl/worksheets/sheet3.xml +2 -0
  130. data/examples/unzipped-sheets/sharedFormulaTest/[Content_Types].xml +2 -0
  131. data/examples/unzipped-sheets/sharedFormulaTest/docProps/app.xml +2 -0
  132. data/examples/unzipped-sheets/sharedFormulaTest/docProps/core.xml +2 -0
  133. data/examples/unzipped-sheets/sharedFormulaTest/docProps/thumbnail.jpeg +0 -0
  134. data/examples/unzipped-sheets/sharedFormulaTest/xl/_rels/workbook.xml.rels +2 -0
  135. data/examples/unzipped-sheets/sharedFormulaTest/xl/calcChain.xml +2 -0
  136. data/examples/unzipped-sheets/sharedFormulaTest/xl/styles.xml +2 -0
  137. data/examples/unzipped-sheets/sharedFormulaTest/xl/theme/theme1.xml +2 -0
  138. data/examples/unzipped-sheets/sharedFormulaTest/xl/workbook.xml +2 -0
  139. data/examples/unzipped-sheets/sharedFormulaTest/xl/worksheets/sheet1.xml +2 -0
  140. data/examples/unzipped-sheets/table-test/[Content_Types].xml +2 -0
  141. data/examples/unzipped-sheets/table-test/docProps/app.xml +2 -0
  142. data/examples/unzipped-sheets/table-test/docProps/core.xml +2 -0
  143. data/examples/unzipped-sheets/table-test/xl/_rels/workbook.xml.rels +2 -0
  144. data/examples/unzipped-sheets/table-test/xl/calcChain.xml +2 -0
  145. data/examples/unzipped-sheets/table-test/xl/printerSettings/printerSettings1.bin +0 -0
  146. data/examples/unzipped-sheets/table-test/xl/sharedStrings.xml +2 -0
  147. data/examples/unzipped-sheets/table-test/xl/styles.xml +2 -0
  148. data/examples/unzipped-sheets/table-test/xl/tables/table1.xml +2 -0
  149. data/examples/unzipped-sheets/table-test/xl/theme/theme1.xml +2 -0
  150. data/examples/unzipped-sheets/table-test/xl/workbook.xml +2 -0
  151. data/examples/unzipped-sheets/table-test/xl/worksheets/_rels/sheet1.xml.rels +2 -0
  152. data/examples/unzipped-sheets/table-test/xl/worksheets/sheet1.xml +2 -0
  153. data/examples/unzipped-sheets/table-test/xl/worksheets/sheet2.xml +2 -0
  154. data/examples/unzipped-sheets/table-test/xl/worksheets/sheet3.xml +2 -0
  155. data/lib/formulae/compile/formula_builder.rb +1 -0
  156. data/lib/formulae/parse/formula_peg.rb +3 -3
  157. data/lib/formulae/parse/formula_peg.txt +3 -3
  158. data/lib/formulae/run/excel_functions.rb +10 -3
  159. data/spec/excel_functions_spec.rb +21 -0
  160. data/spec/formula_peg_spec.rb +3 -0
  161. metadata +156 -3
@@ -0,0 +1,59 @@
1
+ # coding: utf-8
2
+ # Sheet1
3
+ class Sheet1 < Spreadsheet
4
+ def b2; 1.0; end
5
+ def c2; 2.0; end
6
+ def d2; 3.0; end
7
+ def e2; 4.0; end
8
+ def a3; 1.0; end
9
+ def b3_array; @b3_array ||= m(a('b2','e2'),a('a3','a6')) { |r1,r2| r1+r2 }; end
10
+ def b3; @b3 ||= b3_array.array_formula_offset(0,0); end
11
+ def c3; @c3 ||= b3_array.array_formula_offset(0,1); end
12
+ def d3; @d3 ||= b3_array.array_formula_offset(0,2); end
13
+ def e3; @e3 ||= b3_array.array_formula_offset(0,3); end
14
+ def a4; 2.0; end
15
+ def b4; @b4 ||= b3_array.array_formula_offset(1,0); end
16
+ def c4; @c4 ||= b3_array.array_formula_offset(1,1); end
17
+ def d4; @d4 ||= b3_array.array_formula_offset(1,2); end
18
+ def e4; @e4 ||= b3_array.array_formula_offset(1,3); end
19
+ def a5; 3.0; end
20
+ def b5; @b5 ||= b3_array.array_formula_offset(2,0); end
21
+ def c5; @c5 ||= b3_array.array_formula_offset(2,1); end
22
+ def d5; @d5 ||= b3_array.array_formula_offset(2,2); end
23
+ def e5; @e5 ||= b3_array.array_formula_offset(2,3); end
24
+ def a6; 4.0; end
25
+ def b6; @b6 ||= b3_array.array_formula_offset(3,0); end
26
+ def c6; @c6 ||= b3_array.array_formula_offset(3,1); end
27
+ def d6; @d6 ||= b3_array.array_formula_offset(3,2); end
28
+ def e6; @e6 ||= b3_array.array_formula_offset(3,3); end
29
+ def a11; 1.0; end
30
+ def b11_array; @b11_array ||= m(a('a11','a14'),b2) { |r1,r2| r1+r2 }; end
31
+ def b11; @b11 ||= b11_array.array_formula_offset(0,0); end
32
+ def c11; @c11 ||= b11_array.array_formula_offset(0,1); end
33
+ def d11; @d11 ||= b11_array.array_formula_offset(0,2); end
34
+ def e11; @e11 ||= b11_array.array_formula_offset(0,3); end
35
+ def a12; 2.0; end
36
+ def b12; @b12 ||= b11_array.array_formula_offset(1,0); end
37
+ def c12; @c12 ||= b11_array.array_formula_offset(1,1); end
38
+ def d12; @d12 ||= b11_array.array_formula_offset(1,2); end
39
+ def e12; @e12 ||= b11_array.array_formula_offset(1,3); end
40
+ def a13; 3.0; end
41
+ def b13; @b13 ||= b11_array.array_formula_offset(2,0); end
42
+ def c13; @c13 ||= b11_array.array_formula_offset(2,1); end
43
+ def d13; @d13 ||= b11_array.array_formula_offset(2,2); end
44
+ def e13; @e13 ||= b11_array.array_formula_offset(2,3); end
45
+ def a14; 4.0; end
46
+ def b14; @b14 ||= b11_array.array_formula_offset(3,0); end
47
+ def c14; @c14 ||= b11_array.array_formula_offset(3,1); end
48
+ def d14; @d14 ||= b11_array.array_formula_offset(3,2); end
49
+ def e14; @e14 ||= b11_array.array_formula_offset(3,3); end
50
+ def c21_array; @c21_array ||= m(2.0,sheet2.a('b15','e15')) { |r1,r2| r1*r2 }; end
51
+ def c21; @c21 ||= c21_array.array_formula_offset(0,0); end
52
+ def d21; @d21 ||= c21_array.array_formula_offset(0,1); end
53
+ def e21; @e21 ||= c21_array.array_formula_offset(0,2); end
54
+ def f21; @f21 ||= c21_array.array_formula_offset(0,3); end
55
+ def g21; @g21 ||= c21_array.array_formula_offset(0,4); end
56
+ def d24; "This is, hopefully, the first shared string"; end
57
+ def d25; "This a second shared string"; end
58
+ end
59
+
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ # Sheet2
3
+ class Sheet2 < Spreadsheet
4
+ def b15; 2.0; end
5
+ def c15; 4.0; end
6
+ def d15; 6.0; end
7
+ def e15; 8.0; end
8
+ end
9
+
@@ -0,0 +1,156 @@
1
+ # coding: utf-8
2
+ require_relative '../spreadsheet'
3
+ # Sheet1
4
+ describe 'Sheet1' do
5
+ def sheet1; $spreadsheet ||= Spreadsheet.new; $spreadsheet.sheet1; end
6
+
7
+ it 'cell b3 should equal 2.0' do
8
+ sheet1.b3.should be_within(0.2).of(2.0)
9
+ end
10
+
11
+ it 'cell c3 should equal 3.0' do
12
+ sheet1.c3.should be_within(0.30000000000000004).of(3.0)
13
+ end
14
+
15
+ it 'cell d3 should equal 4.0' do
16
+ sheet1.d3.should be_within(0.4).of(4.0)
17
+ end
18
+
19
+ it 'cell e3 should equal 5.0' do
20
+ sheet1.e3.should be_within(0.5).of(5.0)
21
+ end
22
+
23
+ it 'cell b4 should equal 3.0' do
24
+ sheet1.b4.should be_within(0.30000000000000004).of(3.0)
25
+ end
26
+
27
+ it 'cell c4 should equal 4.0' do
28
+ sheet1.c4.should be_within(0.4).of(4.0)
29
+ end
30
+
31
+ it 'cell d4 should equal 5.0' do
32
+ sheet1.d4.should be_within(0.5).of(5.0)
33
+ end
34
+
35
+ it 'cell e4 should equal 6.0' do
36
+ sheet1.e4.should be_within(0.6000000000000001).of(6.0)
37
+ end
38
+
39
+ it 'cell b5 should equal 4.0' do
40
+ sheet1.b5.should be_within(0.4).of(4.0)
41
+ end
42
+
43
+ it 'cell c5 should equal 5.0' do
44
+ sheet1.c5.should be_within(0.5).of(5.0)
45
+ end
46
+
47
+ it 'cell d5 should equal 6.0' do
48
+ sheet1.d5.should be_within(0.6000000000000001).of(6.0)
49
+ end
50
+
51
+ it 'cell e5 should equal 7.0' do
52
+ sheet1.e5.should be_within(0.7000000000000001).of(7.0)
53
+ end
54
+
55
+ it 'cell b6 should equal 5.0' do
56
+ sheet1.b6.should be_within(0.5).of(5.0)
57
+ end
58
+
59
+ it 'cell c6 should equal 6.0' do
60
+ sheet1.c6.should be_within(0.6000000000000001).of(6.0)
61
+ end
62
+
63
+ it 'cell d6 should equal 7.0' do
64
+ sheet1.d6.should be_within(0.7000000000000001).of(7.0)
65
+ end
66
+
67
+ it 'cell e6 should equal 8.0' do
68
+ sheet1.e6.should be_within(0.8).of(8.0)
69
+ end
70
+
71
+ it 'cell b11 should equal 2.0' do
72
+ sheet1.b11.should be_within(0.2).of(2.0)
73
+ end
74
+
75
+ it 'cell c11 should equal 2.0' do
76
+ sheet1.c11.should be_within(0.2).of(2.0)
77
+ end
78
+
79
+ it 'cell d11 should equal 2.0' do
80
+ sheet1.d11.should be_within(0.2).of(2.0)
81
+ end
82
+
83
+ it 'cell e11 should equal 2.0' do
84
+ sheet1.e11.should be_within(0.2).of(2.0)
85
+ end
86
+
87
+ it 'cell b12 should equal 3.0' do
88
+ sheet1.b12.should be_within(0.30000000000000004).of(3.0)
89
+ end
90
+
91
+ it 'cell c12 should equal 3.0' do
92
+ sheet1.c12.should be_within(0.30000000000000004).of(3.0)
93
+ end
94
+
95
+ it 'cell d12 should equal 3.0' do
96
+ sheet1.d12.should be_within(0.30000000000000004).of(3.0)
97
+ end
98
+
99
+ it 'cell e12 should equal 3.0' do
100
+ sheet1.e12.should be_within(0.30000000000000004).of(3.0)
101
+ end
102
+
103
+ it 'cell b13 should equal 4.0' do
104
+ sheet1.b13.should be_within(0.4).of(4.0)
105
+ end
106
+
107
+ it 'cell c13 should equal 4.0' do
108
+ sheet1.c13.should be_within(0.4).of(4.0)
109
+ end
110
+
111
+ it 'cell d13 should equal 4.0' do
112
+ sheet1.d13.should be_within(0.4).of(4.0)
113
+ end
114
+
115
+ it 'cell e13 should equal 4.0' do
116
+ sheet1.e13.should be_within(0.4).of(4.0)
117
+ end
118
+
119
+ it 'cell b14 should equal 5.0' do
120
+ sheet1.b14.should be_within(0.5).of(5.0)
121
+ end
122
+
123
+ it 'cell c14 should equal 5.0' do
124
+ sheet1.c14.should be_within(0.5).of(5.0)
125
+ end
126
+
127
+ it 'cell d14 should equal 5.0' do
128
+ sheet1.d14.should be_within(0.5).of(5.0)
129
+ end
130
+
131
+ it 'cell e14 should equal 5.0' do
132
+ sheet1.e14.should be_within(0.5).of(5.0)
133
+ end
134
+
135
+ it 'cell c21 should equal 4.0' do
136
+ sheet1.c21.should be_within(0.4).of(4.0)
137
+ end
138
+
139
+ it 'cell d21 should equal 8.0' do
140
+ sheet1.d21.should be_within(0.8).of(8.0)
141
+ end
142
+
143
+ it 'cell e21 should equal 12.0' do
144
+ sheet1.e21.should be_within(1.2000000000000002).of(12.0)
145
+ end
146
+
147
+ it 'cell f21 should equal 16.0' do
148
+ sheet1.f21.should be_within(1.6).of(16.0)
149
+ end
150
+
151
+ it 'cell g21 should equal :na' do
152
+ sheet1.g21.should == :na
153
+ end
154
+
155
+ end
156
+
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+ require_relative '../spreadsheet'
3
+ # Sheet2
4
+ describe 'Sheet2' do
5
+ def sheet2; $spreadsheet ||= Spreadsheet.new; $spreadsheet.sheet2; end
6
+
7
+ end
8
+
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ require 'rubyfromexcel'
3
+
4
+ class Spreadsheet
5
+ include RubyFromExcel::ExcelFunctions
6
+
7
+ end
8
+
9
+ Dir[File.join(File.dirname(__FILE__),"sheets/","sheet*.rb")].each {|f| Spreadsheet.autoload(File.basename(f,".rb").capitalize,f)}
@@ -0,0 +1,307 @@
1
+ # coding: utf-8
2
+ # EU
3
+ class Sheet1 < Spreadsheet
4
+ def b1; "Note, numbers not checked. Worry about power sector figure. Worry about the UK share of auction revenues."; end
5
+ def d2; "Expansion"; end
6
+ def d3; "Additions"; end
7
+ def o3; "Annual"; end
8
+ def b4; "EU-27 Emissions"; end
9
+ def c4; "2005-6"; end
10
+ def d4; "Phase II"; end
11
+ def e4; "Phase III"; end
12
+ def f4; 2013.0; end
13
+ def g4; 2014.0; end
14
+ def h4; 2015.0; end
15
+ def i4; 2016.0; end
16
+ def j4; 2017.0; end
17
+ def k4; 2018.0; end
18
+ def l4; 2019.0; end
19
+ def m4; 2020.0; end
20
+ def o4; "Change"; end
21
+ def b5; "Power sector"; end
22
+ def c5; 1150.0; end
23
+ def d5; 50.0; end
24
+ def e5; 50.0; end
25
+ def f5; @f5 ||= +(c5+d5+e5)*0.9; end
26
+ def g5; @g5 ||= f5*(1.0-o5); end
27
+ def h5; @h5 ||= g5*(1.0-o5); end
28
+ def i5; @i5 ||= h5*(1.0-o5); end
29
+ def j5; @j5 ||= i5*(1.0-o5); end
30
+ def k5; @k5 ||= j5*(1.0-o5); end
31
+ def l5; @l5 ||= k5*(1.0-o5); end
32
+ def m5; @m5 ||= l5*(1.0-o5); end
33
+ def n5; "mtCO2"; end
34
+ def o5; 0.02; end
35
+ def b6; "Leakage sectors"; end
36
+ def c6; 350.0; end
37
+ def f6; @f6 ||= +(c6+d6+e6)*0.95; end
38
+ def g6; @g6 ||= f6*(1.0-o5); end
39
+ def h6; @h6 ||= g6*(1.0-o5); end
40
+ def i6; @i6 ||= h6*(1.0-o5); end
41
+ def j6; @j6 ||= i6*(1.0-o5); end
42
+ def k6; @k6 ||= j6*(1.0-o5); end
43
+ def l6; @l6 ||= k6*(1.0-o5); end
44
+ def m6; @m6 ||= l6*(1.0-o5); end
45
+ def n6; "mtCO2"; end
46
+ def o6; 0.01; end
47
+ def b7; "Other sectors"; end
48
+ def c7; 550.0; end
49
+ def d7; 100.0; end
50
+ def e7; 100.0; end
51
+ def f7; @f7 ||= +(c7+d7+e7)*0.95; end
52
+ def g7; @g7 ||= f7*(1.0-o5); end
53
+ def h7; @h7 ||= g7*(1.0-o5); end
54
+ def i7; @i7 ||= h7*(1.0-o5); end
55
+ def j7; @j7 ||= i7*(1.0-o5); end
56
+ def k7; @k7 ||= j7*(1.0-o5); end
57
+ def l7; @l7 ||= k7*(1.0-o5); end
58
+ def m7; @m7 ||= l7*(1.0-o5); end
59
+ def n7; "mtCO2"; end
60
+ def o7; 0.01; end
61
+ def b8; "Total"; end
62
+ def f8; @f8 ||= +sum(a('f5','f7')); end
63
+ def g8; @g8 ||= +sum(a('g5','g7')); end
64
+ def h8; @h8 ||= +sum(a('h5','h7')); end
65
+ def i8; @i8 ||= +sum(a('i5','i7')); end
66
+ def j8; @j8 ||= +sum(a('j5','j7')); end
67
+ def k8; @k8 ||= +sum(a('k5','k7')); end
68
+ def l8; @l8 ||= +sum(a('l5','l7')); end
69
+ def m8; @m8 ||= +sum(a('m5','m7')); end
70
+ def n8; "mtCO2"; end
71
+ def b10; "Proportion allocated for free"; end
72
+ def f10; @f10 ||= f4; end
73
+ def g10; @g10 ||= g4; end
74
+ def h10; @h10 ||= h4; end
75
+ def i10; @i10 ||= i4; end
76
+ def j10; @j10 ||= j4; end
77
+ def k10; @k10 ||= k4; end
78
+ def l10; @l10 ||= l4; end
79
+ def m10; @m10 ||= m4; end
80
+ def b11; "Power sector"; end
81
+ def f11; 0.0; end
82
+ def g11; @g11 ||= f11; end
83
+ def h11; @h11 ||= g11; end
84
+ def i11; @i11 ||= h11; end
85
+ def j11; @j11 ||= i11; end
86
+ def k11; @k11 ||= j11; end
87
+ def l11; @l11 ||= k11; end
88
+ def m11; @m11 ||= l11; end
89
+ def n11; "%"; end
90
+ def b12; @b12 ||= +b6; end
91
+ def f12; 0.9; end
92
+ def g12; @g12 ||= +f12+o12; end
93
+ def h12; @h12 ||= +g12+o12; end
94
+ def i12; @i12 ||= +h12+o12; end
95
+ def j12; @j12 ||= +i12+o12; end
96
+ def k12; @k12 ||= +j12+o12; end
97
+ def l12; @l12 ||= +k12+o12; end
98
+ def m12; @m12 ||= +l12+o12; end
99
+ def o12; -0.025; end
100
+ def b13; "Other"; end
101
+ def f13; 0.8; end
102
+ def g13; @g13 ||= f13+o13; end
103
+ def h13; @h13 ||= g13+o13; end
104
+ def i13; @i13 ||= h13+o13; end
105
+ def j13; @j13 ||= i13+o13; end
106
+ def k13; @k13 ||= j13+o13; end
107
+ def l13; @l13 ||= k13+o13; end
108
+ def m13; 0.0; end
109
+ def n13; "%"; end
110
+ def o13; @o13 ||= (m13-f13)/(m10-f10); end
111
+ def b14; "Average non-power sectors"; end
112
+ def f14; @f14 ||= +(f6*f12+f7*f13)/(f6+f7); end
113
+ def g14; @g14 ||= +(g6*g12+g7*g13)/(g6+g7); end
114
+ def h14; @h14 ||= +(h6*h12+h7*h13)/(h6+h7); end
115
+ def i14; @i14 ||= +(i6*i12+i7*i13)/(i6+i7); end
116
+ def j14; @j14 ||= +(j6*j12+j7*j13)/(j6+j7); end
117
+ def k14; @k14 ||= +(k6*k12+k7*k13)/(k6+k7); end
118
+ def l14; @l14 ||= +(l6*l12+l7*l13)/(l6+l7); end
119
+ def m14; @m14 ||= +(m6*m12+m7*m13)/(m6+m7); end
120
+ def b15; "Total free allocation, % emissions"; end
121
+ def f15; @f15 ||= ((f11*f5)+(f12*f6)+(f13*f7))/f8; end
122
+ def g15; @g15 ||= ((g11*g5)+(g12*g6)+(g13*g7))/g8; end
123
+ def h15; @h15 ||= ((h11*h5)+(h12*h6)+(h13*h7))/h8; end
124
+ def i15; @i15 ||= ((i11*i5)+(i12*i6)+(i13*i7))/i8; end
125
+ def j15; @j15 ||= ((j11*j5)+(j12*j6)+(j13*j7))/j8; end
126
+ def k15; @k15 ||= ((k11*k5)+(k12*k6)+(k13*k7))/k8; end
127
+ def l15; @l15 ||= ((l11*l5)+(l12*l6)+(l13*l7))/l8; end
128
+ def m15; @m15 ||= ((m11*m5)+(m12*m6)+(m13*m7))/m8; end
129
+ def n15; "%"; end
130
+ def b17; "Proportion auctioned, other sectors"; end
131
+ def f17; @f17 ||= 1.0-f14; end
132
+ def g17; @g17 ||= 1.0-g14; end
133
+ def h17; @h17 ||= 1.0-h14; end
134
+ def i17; @i17 ||= 1.0-i14; end
135
+ def j17; @j17 ||= 1.0-j14; end
136
+ def k17; @k17 ||= 1.0-k14; end
137
+ def l17; @l17 ||= 1.0-l14; end
138
+ def m17; @m17 ||= 1.0-m14; end
139
+ def b18; "Total allowances"; end
140
+ def d18; 2010.0; end
141
+ def f18; @f18 ||= f10; end
142
+ def g18; @g18 ||= g10; end
143
+ def h18; @h18 ||= h10; end
144
+ def i18; @i18 ||= i10; end
145
+ def j18; @j18 ||= j10; end
146
+ def k18; @k18 ||= k10; end
147
+ def l18; @l18 ||= l10; end
148
+ def m18; @m18 ||= m10; end
149
+ def b19; "Total allowances"; end
150
+ def d19; @d19 ||= +(2100.0+100.0)*0.935+150.0; end
151
+ def f19; @f19 ||= +d19*(1.0-3.0*o19); end
152
+ def g19; @g19 ||= +f19*(1.0-o19); end
153
+ def h19; @h19 ||= +g19*(1.0-o19); end
154
+ def i19; @i19 ||= +h19*(1.0-o19); end
155
+ def j19; @j19 ||= +i19*(1.0-o19); end
156
+ def k19; @k19 ||= +j19*(1.0-o19); end
157
+ def l19; @l19 ||= +k19*(1.0-o19); end
158
+ def m19; @m19 ||= +l19*(1.0-o19); end
159
+ def o19; 0.0174; end
160
+ def p19; "Note: 1720 \"based on current scope\""; end
161
+ def b20; "Total free allocation, MtCO2"; end
162
+ def f20; @f20 ||= +f6*f12+f7*f13*f19/f8; end
163
+ def g20; @g20 ||= +f6*g12+f7*g13*g19/g8; end
164
+ def h20; @h20 ||= +f6*h12+f7*h13*h19/h8; end
165
+ def i20; @i20 ||= +f6*i12+f7*i13*i19/i8; end
166
+ def j20; @j20 ||= +f6*j12+f7*j13*j19/j8; end
167
+ def k20; @k20 ||= +f6*k12+f7*k13*k19/k8; end
168
+ def l20; @l20 ||= +f6*l12+f7*l13*l19/l8; end
169
+ def m20; @m20 ||= +f6*m12+f7*m13*m19/m8; end
170
+ def b21; "Volume available for auctioning"; end
171
+ def f21; @f21 ||= +f19-f20; end
172
+ def g21; @g21 ||= +g19-g20; end
173
+ def h21; @h21 ||= +h19-h20; end
174
+ def i21; @i21 ||= +i19-i20; end
175
+ def j21; @j21 ||= +j19-j20; end
176
+ def k21; @k21 ||= +k19-k20; end
177
+ def l21; @l21 ||= +l19-l20; end
178
+ def m21; @m21 ||= +m19-m20; end
179
+ def b23; "Carbon Price"; end
180
+ def f23; @f23 ||= f10; end
181
+ def g23; @g23 ||= g10; end
182
+ def h23; @h23 ||= h10; end
183
+ def i23; @i23 ||= i10; end
184
+ def j23; @j23 ||= j10; end
185
+ def k23; @k23 ||= k10; end
186
+ def l23; @l23 ||= l10; end
187
+ def m23; @m23 ||= m10; end
188
+ def b24; "Price per allowance"; end
189
+ def f24; 25.0; end
190
+ def g24; @g24 ||= +f24*(1.0+o24); end
191
+ def h24; @h24 ||= +g24*(1.0+o24); end
192
+ def i24; @i24 ||= +h24*(1.0+o24); end
193
+ def j24; @j24 ||= +i24*(1.0+o24); end
194
+ def k24; @k24 ||= +j24*(1.0+o24); end
195
+ def l24; @l24 ||= +k24*(1.0+o24); end
196
+ def m24; @m24 ||= +l24*(1.0+o24); end
197
+ def n24; "€/tCO2"; end
198
+ def o24; 0.05; end
199
+ def b25; "Total revenue from auctions"; end
200
+ def f25; @f25 ||= +f24*f21; end
201
+ def g25; @g25 ||= +g24*g21; end
202
+ def h25; @h25 ||= +h24*h21; end
203
+ def i25; @i25 ||= +i24*i21; end
204
+ def j25; @j25 ||= +j24*j21; end
205
+ def k25; @k25 ||= +k24*k21; end
206
+ def l25; @l25 ||= +l24*l21; end
207
+ def m25; @m25 ||= +m24*m21; end
208
+ def b27; "EU-27 Auction volumes- bought into proportion to net shortfall"; end
209
+ def f27; @f27 ||= f10; end
210
+ def g27; @g27 ||= g10; end
211
+ def h27; @h27 ||= h10; end
212
+ def i27; @i27 ||= i10; end
213
+ def j27; @j27 ||= j10; end
214
+ def k27; @k27 ||= k10; end
215
+ def l27; @l27 ||= l10; end
216
+ def m27; @m27 ||= m10; end
217
+ def o27; @o27 ||= sheet2.n17; end
218
+ def b28; "Power sector"; end
219
+ def f28; @f28 ||= +f5*(1.0-f11)*(f19/f8); end
220
+ def g28; @g28 ||= +g5*(1.0-g11)*(g19/g8); end
221
+ def h28; @h28 ||= +h5*(1.0-h11)*(h19/h8); end
222
+ def i28; @i28 ||= +i5*(1.0-i11)*(i19/i8); end
223
+ def j28; @j28 ||= +j5*(1.0-j11)*(j19/j8); end
224
+ def k28; @k28 ||= +k5*(1.0-k11)*(k19/k8); end
225
+ def l28; @l28 ||= +l5*(1.0-l11)*(l19/l8); end
226
+ def m28; @m28 ||= +m5*(1.0-m11)*(m19/m8); end
227
+ def o28; @o28 ||= sheet2.c18; end
228
+ def b29; @b29 ||= +b6; end
229
+ def f29; @f29 ||= +f6*(1.0-f12)*(f19/f8); end
230
+ def g29; @g29 ||= +g6*(1.0-g12)*(g19/g8); end
231
+ def h29; @h29 ||= +h6*(1.0-h12)*(h19/h8); end
232
+ def i29; @i29 ||= +i6*(1.0-i12)*(i19/i8); end
233
+ def j29; @j29 ||= +j6*(1.0-j12)*(j19/j8); end
234
+ def k29; @k29 ||= +k6*(1.0-k12)*(k19/k8); end
235
+ def l29; @l29 ||= +l6*(1.0-l12)*(l19/l8); end
236
+ def m29; @m29 ||= +m6*(1.0-m12)*(m19/m8); end
237
+ def b30; "Other"; end
238
+ def f30; @f30 ||= +f7*(1.0-f13)*(f19/f8); end
239
+ def g30; @g30 ||= +g7*(1.0-g13)*(g19/g8); end
240
+ def h30; @h30 ||= +h7*(1.0-h13)*(h19/h8); end
241
+ def i30; @i30 ||= +i7*(1.0-i13)*(i19/i8); end
242
+ def j30; @j30 ||= +j7*(1.0-j13)*(j19/j8); end
243
+ def k30; @k30 ||= +k7*(1.0-k13)*(k19/k8); end
244
+ def l30; @l30 ||= +l7*(1.0-l13)*(l19/l8); end
245
+ def m30; @m30 ||= +m7*(1.0-m13)*(m19/m8); end
246
+ def b31; "Total"; end
247
+ def f31; @f31 ||= +sum(a('f28','f30')); end
248
+ def g31; @g31 ||= +sum(a('g28','g30')); end
249
+ def h31; @h31 ||= +sum(a('h28','h30')); end
250
+ def i31; @i31 ||= +sum(a('i28','i30')); end
251
+ def j31; @j31 ||= +sum(a('j28','j30')); end
252
+ def k31; @k31 ||= +sum(a('k28','k30')); end
253
+ def l31; @l31 ||= +sum(a('l28','l30')); end
254
+ def m31; @m31 ||= +sum(a('m28','m30')); end
255
+ def b33; "Revenues"; end
256
+ def b34; "Power sector"; end
257
+ def f34; @f34 ||= +f28*f24; end
258
+ def g34; @g34 ||= +g28*g24; end
259
+ def h34; @h34 ||= +h28*h24; end
260
+ def i34; @i34 ||= +i28*i24; end
261
+ def j34; @j34 ||= +j28*j24; end
262
+ def k34; @k34 ||= +k28*k24; end
263
+ def l34; @l34 ||= +l28*l24; end
264
+ def m34; @m34 ||= +m28*m24; end
265
+ def b35; "Other sectors"; end
266
+ def f35; @f35 ||= +(f29+f30)*f24; end
267
+ def g35; @g35 ||= +(g29+g30)*g24; end
268
+ def h35; @h35 ||= +(h29+h30)*h24; end
269
+ def i35; @i35 ||= +(i29+i30)*i24; end
270
+ def j35; @j35 ||= +(j29+j30)*j24; end
271
+ def k35; @k35 ||= +(k29+k30)*k24; end
272
+ def l35; @l35 ||= +(l29+l30)*l24; end
273
+ def m35; @m35 ||= +(m29+m30)*m24; end
274
+ def b39; "2005 UK ETS Emissions"; end
275
+ def f39; 242.0; end
276
+ def g39; "mtCO2"; end
277
+ def n39; " "; end
278
+ def b40; "2005 EU ETS Emissions"; end
279
+ def f40; 1785.0; end
280
+ def g40; "mtCO2"; end
281
+ def b41; "Basic UK share of auction revenues"; end
282
+ def f41; @f41 ||= f39/f40; end
283
+ def b42; "Amount of share auctioned in UK"; end
284
+ def f42; 0.9; end
285
+ def b43; "Actual UK share of auction revenues"; end
286
+ def f43; @f43 ||= f42*f41; end
287
+ def b45; "UK Auction revenues"; end
288
+ def f45; @f45 ||= f4; end
289
+ def g45; @g45 ||= g4; end
290
+ def h45; @h45 ||= h4; end
291
+ def i45; @i45 ||= i4; end
292
+ def j45; @j45 ||= j4; end
293
+ def k45; @k45 ||= k4; end
294
+ def l45; @l45 ||= l4; end
295
+ def m45; @m45 ||= m4; end
296
+ def b46; "Total"; end
297
+ def f46; @f46 ||= f43*f31; end
298
+ def g46; @g46 ||= f43*g31; end
299
+ def h46; @h46 ||= f43*h31; end
300
+ def i46; @i46 ||= f43*i31; end
301
+ def j46; @j46 ||= f43*j31; end
302
+ def k46; @k46 ||= f43*k31; end
303
+ def l46; @l46 ||= f43*l31; end
304
+ def m46; @m46 ||= f43*m31; end
305
+ def n46; "€bn"; end
306
+ end
307
+