excel_to_code 0.1.23 → 0.2.0
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/src/commands/excel_to_c.rb +39 -92
- data/src/commands/excel_to_ruby.rb +9 -35
- data/src/commands/excel_to_x.rb +515 -536
- data/src/compile/c/a.out +0 -0
- data/src/compile/c/compile_named_reference_setters.rb +4 -6
- data/src/compile/c/compile_to_c.rb +34 -21
- data/src/compile/c/compile_to_c_header.rb +7 -7
- data/src/compile/c/excel_to_c_runtime.c +8 -4
- data/src/compile/c/map_formulae_to_c.rb +85 -86
- data/src/compile/c/map_values_to_c.rb +7 -1
- data/src/compile/c/map_values_to_c_structs.rb +1 -1
- data/src/compile/ruby/compile_to_ruby.rb +14 -11
- data/src/compile/ruby/compile_to_ruby_unit_test.rb +17 -10
- data/src/compile/ruby/map_formulae_to_ruby.rb +56 -56
- data/src/compile/ruby/map_values_to_ruby.rb +14 -2
- data/src/excel/area.rb +6 -8
- data/src/excel/excel_functions/hlookup.rb +1 -1
- data/src/excel/excel_functions/vlookup.rb +1 -1
- data/src/excel/formula_peg.rb +1 -1
- data/src/excel/formula_peg.txt +1 -1
- data/src/excel/reference.rb +4 -3
- data/src/excel/table.rb +4 -4
- data/src/extract.rb +1 -0
- data/src/extract/check_for_unknown_functions.rb +2 -2
- data/src/extract/extract_array_formulae.rb +9 -9
- data/src/extract/extract_everything.rb +140 -0
- data/src/extract/extract_formulae.rb +30 -20
- data/src/extract/extract_named_references.rb +37 -22
- data/src/extract/extract_relationships.rb +16 -3
- data/src/extract/extract_shared_formulae.rb +8 -11
- data/src/extract/extract_shared_formulae_targets.rb +1 -6
- data/src/extract/extract_shared_strings.rb +21 -8
- data/src/extract/extract_simple_formulae.rb +11 -6
- data/src/extract/extract_table.rb +26 -13
- data/src/extract/extract_values.rb +35 -11
- data/src/extract/extract_worksheet_dimensions.rb +13 -3
- data/src/extract/extract_worksheet_names.rb +16 -3
- data/src/extract/extract_worksheet_table_relationships.rb +16 -4
- data/src/extract/simple_extract_from_xml.rb +9 -11
- data/src/rewrite.rb +3 -0
- data/src/rewrite/ast_copy_formula.rb +5 -1
- data/src/rewrite/ast_expand_array_formulae.rb +71 -59
- data/src/rewrite/caching_formula_parser.rb +110 -0
- data/src/rewrite/rewrite_array_formulae.rb +21 -14
- data/src/rewrite/rewrite_cell_references_to_include_sheet.rb +41 -13
- data/src/rewrite/rewrite_shared_formulae.rb +17 -18
- data/src/rewrite/rewrite_values_to_ast.rb +2 -0
- data/src/rewrite/rewrite_whole_row_column_references_to_areas.rb +28 -25
- data/src/simplify.rb +1 -0
- data/src/simplify/count_formula_references.rb +22 -23
- data/src/simplify/emergency_array_formula_replace_indirect_bodge.rb +44 -0
- data/src/simplify/identify_dependencies.rb +7 -8
- data/src/simplify/identify_repeated_formula_elements.rb +5 -6
- data/src/simplify/inline_formulae.rb +48 -48
- data/src/simplify/map_formulae_to_values.rb +197 -79
- data/src/simplify/remove_cells.rb +13 -6
- data/src/simplify/replace_arithmetic_on_ranges.rb +42 -28
- data/src/simplify/replace_arrays_with_single_cells.rb +11 -5
- data/src/simplify/replace_column_with_column_number.rb +31 -23
- data/src/simplify/replace_common_elements_in_formulae.rb +16 -17
- data/src/simplify/replace_indirects_with_references.rb +26 -21
- data/src/simplify/replace_named_references.rb +26 -31
- data/src/simplify/replace_offsets_with_references.rb +33 -34
- data/src/simplify/replace_ranges_with_array_literals.rb +48 -20
- data/src/simplify/replace_shared_strings.rb +15 -13
- data/src/simplify/replace_string_join_on_ranges.rb +7 -9
- data/src/simplify/replace_table_references.rb +16 -11
- data/src/simplify/replace_values_with_constants.rb +6 -4
- data/src/simplify/simplify_arithmetic.rb +33 -19
- data/src/simplify/sort_into_calculation_order.rb +13 -13
- data/src/simplify/wrap_formulae_that_return_arrays_and_are_not_in_arrays.rb +21 -13
- metadata +19 -2
@@ -1,5 +1,21 @@
|
|
1
1
|
require_relative '../excel'
|
2
2
|
|
3
|
+
class WrapFormulaeThatReturnArraysAndAReNotInArraysAst
|
4
|
+
def map(ast)
|
5
|
+
return ast unless ast.is_a?(Array)
|
6
|
+
function(ast) if ast.first == :function
|
7
|
+
ast
|
8
|
+
end
|
9
|
+
|
10
|
+
# Only does MMULT at the moment
|
11
|
+
FORMULAE_THAT_RETURN_ARRAYS = { "MMULT" => true }
|
12
|
+
|
13
|
+
def function(ast)
|
14
|
+
return unless FORMULAE_THAT_RETURN_ARRAYS.has_key?(ast[1])
|
15
|
+
ast.replace( [:function, "INDEX", ast.dup, [:number, "1"], [:number, "1"]])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
class WrapFormulaeThatReturnArraysAndAReNotInArrays
|
4
20
|
|
5
21
|
def self.replace(*args)
|
@@ -7,21 +23,13 @@ class WrapFormulaeThatReturnArraysAndAReNotInArrays
|
|
7
23
|
end
|
8
24
|
|
9
25
|
def replace(input,output)
|
10
|
-
|
26
|
+
r = WrapFormulaeThatReturnArraysAndAReNotInArraysAst.new
|
27
|
+
|
11
28
|
input.each_line do |line|
|
12
29
|
# Looks to match lines that contain formulae that return ranges, such as MMULT
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if ast[0] == :function && ast[1] == "MMULT"
|
17
|
-
new_ast = [:function, "INDEX", ast, [:number, "1"], [:number, "1"]]
|
18
|
-
output.puts "#{content.join("\t")}\t#{new_ast.inspect}"
|
19
|
-
else
|
20
|
-
output.puts line
|
21
|
-
end
|
22
|
-
else
|
23
|
-
output.puts line
|
24
|
-
end
|
30
|
+
content = line.split("\t")
|
31
|
+
ast = eval(content.pop)
|
32
|
+
output.puts "#{content.join("\t")}\t#{r.map(ast).inspect}"
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_to_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Counsell, Green on Black Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.0.11
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ox
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.12
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.12
|
69
83
|
description: "# excel_to_code\n\nConverts some excel spreadsheets (.xlsx, not .xls)
|
70
84
|
into some other programming languages (currently ruby or c).\nThis allows the excel
|
71
85
|
spreadsheets to be run programatically, without excel.\n\nIts cannonical source
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- src/excel_to_code.rb
|
185
199
|
- src/extract/check_for_unknown_functions.rb
|
186
200
|
- src/extract/extract_array_formulae.rb
|
201
|
+
- src/extract/extract_everything.rb
|
187
202
|
- src/extract/extract_formulae.rb
|
188
203
|
- src/extract/extract_named_references.rb
|
189
204
|
- src/extract/extract_relationships.rb
|
@@ -200,6 +215,7 @@ files:
|
|
200
215
|
- src/extract.rb
|
201
216
|
- src/rewrite/ast_copy_formula.rb
|
202
217
|
- src/rewrite/ast_expand_array_formulae.rb
|
218
|
+
- src/rewrite/caching_formula_parser.rb
|
203
219
|
- src/rewrite/rewrite_array_formulae.rb
|
204
220
|
- src/rewrite/rewrite_array_formulae_to_arrays.rb
|
205
221
|
- src/rewrite/rewrite_cell_references_to_include_sheet.rb
|
@@ -213,6 +229,7 @@ files:
|
|
213
229
|
- src/rewrite/rewrite_worksheet_names.rb
|
214
230
|
- src/rewrite.rb
|
215
231
|
- src/simplify/count_formula_references.rb
|
232
|
+
- src/simplify/emergency_array_formula_replace_indirect_bodge.rb
|
216
233
|
- src/simplify/identify_dependencies.rb
|
217
234
|
- src/simplify/identify_repeated_formula_elements.rb
|
218
235
|
- src/simplify/inline_formulae.rb
|