excel_to_code 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/excel_to_c +0 -4
- data/bin/excel_to_ruby +0 -4
- data/src/commands/excel_to_c.rb +7 -27
- data/src/commands/excel_to_ruby.rb +2 -2
- data/src/commands/excel_to_x.rb +215 -175
- data/src/compile/c/a.out +0 -0
- data/src/compile/c/excel_to_c_runtime.c +39 -806
- data/src/compile/c/excel_to_c_runtime_test.c +759 -0
- data/src/compile/ruby/map_formulae_to_ruby.rb +1 -0
- data/src/excel/excel_functions.rb +2 -0
- data/src/excel/excel_functions/lower.rb +21 -0
- data/src/extract.rb +1 -10
- data/src/extract/{extract_everything.rb → extract_data_from_worksheet.rb} +1 -1
- metadata +30 -39
- data/src/extract/check_for_unknown_functions.rb +0 -20
- data/src/extract/extract_array_formulae.rb +0 -23
- data/src/extract/extract_formulae.rb +0 -46
- data/src/extract/extract_shared_formulae.rb +0 -24
- data/src/extract/extract_shared_formulae_targets.rb +0 -15
- data/src/extract/extract_simple_formulae.rb +0 -23
- data/src/extract/extract_values.rb +0 -53
- data/src/extract/extract_worksheet_dimensions.rb +0 -21
- data/src/extract/extract_worksheet_table_relationships.rb +0 -22
- data/src/extract/simple_extract_from_xml.rb +0 -17
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
class ExtractValues < Nokogiri::XML::SAX::Document
|
4
|
-
|
5
|
-
def self.extract(*args)
|
6
|
-
self.new.extract(*args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def extract(sheet_name, input)
|
10
|
-
@sheet_name = sheet_name.to_sym
|
11
|
-
@output = {}
|
12
|
-
@parsing = false
|
13
|
-
@fp = CachingFormulaParser.instance
|
14
|
-
Nokogiri::XML::SAX::Parser.new(self).parse(input)
|
15
|
-
@output
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_accessor :ref, :type, :value
|
19
|
-
|
20
|
-
def start_element(name,attributes)
|
21
|
-
if name == "v"
|
22
|
-
@parsing = true
|
23
|
-
@value = []
|
24
|
-
elsif name == "c"
|
25
|
-
@ref = attributes.assoc('r').last.to_sym
|
26
|
-
type = attributes.assoc('t')
|
27
|
-
@type = type ? type.last : "n"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def end_element(name)
|
32
|
-
return unless name == "v"
|
33
|
-
@parsing = false
|
34
|
-
value = @value.join
|
35
|
-
ast = case @type
|
36
|
-
when 'b'; value == "1" ? [:boolean_true] : [:boolean_false]
|
37
|
-
when 's'; [:shared_string,value.to_i]
|
38
|
-
when 'n'; [:number,value.to_f]
|
39
|
-
when 'e'; [:error,value.to_sym]
|
40
|
-
when 'str'; [:string,value.gsub(/_x[0-9A-F]{4}_/,'').freeze]
|
41
|
-
else
|
42
|
-
$stderr.puts "Type #{type} not known #{@sheet_name} #{@ref}"
|
43
|
-
exit
|
44
|
-
end
|
45
|
-
@output[[@sheet_name, @ref]] = @fp.map(ast)
|
46
|
-
end
|
47
|
-
|
48
|
-
def characters(string)
|
49
|
-
return unless @parsing
|
50
|
-
@value << string
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
class ExtractWorksheetDimensions < Nokogiri::XML::SAX::Document
|
4
|
-
|
5
|
-
def self.extract(*args)
|
6
|
-
self.new.extract(*args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def extract(input)
|
10
|
-
parser = Nokogiri::XML::SAX::Parser.new(self)
|
11
|
-
parser.parse(input)
|
12
|
-
@output
|
13
|
-
end
|
14
|
-
|
15
|
-
# FIXME: Is there an elegant way to abort once we have found the dimension tag?
|
16
|
-
def start_element(name,attributes)
|
17
|
-
return false unless name == "dimension"
|
18
|
-
@output = attributes.assoc('ref').last
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
|
4
|
-
class ExtractWorksheetTableRelationships < Nokogiri::XML::SAX::Document
|
5
|
-
|
6
|
-
def self.extract(*args)
|
7
|
-
self.new.extract(*args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def extract(input)
|
11
|
-
@output = []
|
12
|
-
@parsing = false
|
13
|
-
Nokogiri::XML::SAX::Parser.new(self).parse(input)
|
14
|
-
@output
|
15
|
-
end
|
16
|
-
|
17
|
-
def start_element(name,attributes)
|
18
|
-
return false unless name == "tablePart"
|
19
|
-
@output << "#{attributes.assoc('r:id').last}"
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
class SimpleExtractFromXML < Nokogiri::XML::SAX::Document
|
4
|
-
|
5
|
-
def self.extract(*args)
|
6
|
-
self.new.extract(*args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def extract(sheet_name, input)
|
10
|
-
@sheet_name = sheet_name
|
11
|
-
@output = {}
|
12
|
-
@parsing = false
|
13
|
-
Nokogiri::XML::SAX::Parser.new(self).parse(input)
|
14
|
-
@output
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|