excel_to_code 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/src/commands/excel_to_c.rb +1 -1
- data/src/excel/excel_functions/pmt.rb +1 -0
- data/src/excel/excel_functions/power.rb +1 -1
- data/src/excel_to_code.rb +1 -1
- data/src/extract/extract_data_from_worksheet.rb +10 -1
- data/src/rewrite/caching_formula_parser.rb +5 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4708f58031f15c26a9b1f63bafefb4f1188044a6
|
4
|
+
data.tar.gz: 384d5599d104b8591a1dd38344da83e1d118efab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a6c02501134cc3e84a4814e403add71e6bed25d8252f16ea93c8e4e964a21f3a192b644759fcc0409c91f2bb72de87a3b77292e10c542bd8ff546b636869e57
|
7
|
+
data.tar.gz: 0f37ecbf4955e480e421f24eedb74b2f88b641ac82202a817e6052ba021493d1a15ec41bd37e347bea6c2652ca5887040843285f7aa1b80909fd70d21e24bcd8
|
data/README.md
CHANGED
@@ -45,7 +45,6 @@ There are some how to guides in the doc folder.
|
|
45
45
|
4. Doesn't implement references that involve range unions and lists (but does implement standard ranges)
|
46
46
|
5. Sometimes gives cells as being empty, when excel would give the cell as having a numeric value of zero
|
47
47
|
6. The generated C version does not multithread and will give bad results if you try
|
48
|
-
7.
|
49
|
-
8. The generated code uses
|
50
|
-
|
51
|
-
10. Ranges like this: Sheet1!A10:Sheet1!B20 and 3D ranges don't work
|
48
|
+
7. The generated code uses floating point, rather than fully precise arithmetic, so results can differ slightly
|
49
|
+
8. The generated code uses the sprintf approach to rounding (even-odd) rather than excel's 0.5 rounds away from zero.
|
50
|
+
90. Ranges like this: Sheet1!A10:Sheet1!B20 and 3D ranges don't work
|
data/src/commands/excel_to_c.rb
CHANGED
@@ -239,7 +239,7 @@ class #{ruby_module_name}
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
return a
|
242
|
-
when :ExcelError; [:value,:name,:div0,:ref,:na][excel_value[:number]]
|
242
|
+
when :ExcelError; [:value,:name,:div0,:ref,:na,:num][excel_value[:number]]
|
243
243
|
else
|
244
244
|
raise Exception.new("ExcelValue type \u0023{excel_value[:type].inspect} not recognised")
|
245
245
|
end
|
@@ -8,6 +8,7 @@ module ExcelFunctions
|
|
8
8
|
return rate if rate.is_a?(Symbol)
|
9
9
|
return number_of_periods if number_of_periods.is_a?(Symbol)
|
10
10
|
return present_value if present_value.is_a?(Symbol)
|
11
|
+
return :num if number_of_periods == 0
|
11
12
|
|
12
13
|
return -(present_value / number_of_periods) if rate == 0
|
13
14
|
-present_value*(rate*((1+rate)**number_of_periods))/(((1+rate)**number_of_periods)-1)
|
data/src/excel_to_code.rb
CHANGED
@@ -69,7 +69,7 @@ class ExtractDataFromWorksheet < ::Ox::Sax
|
|
69
69
|
when 's'; [:shared_string, value.to_i]
|
70
70
|
when 'n'; [:number, value.to_f]
|
71
71
|
when 'e'; [:error, value.to_sym]
|
72
|
-
when 'str'; [:string, value
|
72
|
+
when 'str'; [:string, convert_excels_unicode_escaping(value).freeze]
|
73
73
|
else
|
74
74
|
$stderr.puts "Value of type #{@value_type} not known #{@sheet_name} #{@ref}"
|
75
75
|
exit
|
@@ -146,4 +146,13 @@ class ExtractDataFromWorksheet < ::Ox::Sax
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
# Excel encodes unicode as _x000D_ where the 000D
|
150
|
+
# is the unicode codepoint
|
151
|
+
def convert_excels_unicode_escaping(excel_string)
|
152
|
+
excel_string.gsub(/_x([0-9A-F]{4})_/) do
|
153
|
+
unicode_codepoint = $1
|
154
|
+
[unicode_codepoint.hex].pack("U")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
149
158
|
end
|
@@ -94,6 +94,11 @@ class CachingFormulaParser
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def sheet_reference(ast)
|
97
|
+
# Sheet names shouldn't start with [1], because those are
|
98
|
+
# external references
|
99
|
+
if ast[1] =~ /^\[\d+\]/
|
100
|
+
raise ExternalReferenceException.new(ast, @full_ast, @text)
|
101
|
+
end
|
97
102
|
ast[1] = ast[1].to_sym
|
98
103
|
ast[2] = map(ast[2])
|
99
104
|
# We do this to deal with Control!#REF! style rerferences
|
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.3.
|
4
|
+
version: 0.3.14
|
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: 2015-03-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|
@@ -102,11 +102,11 @@ description: "# excel_to_code\n\nConverts some excel spreadsheets (.xlsx, not .x
|
|
102
102
|
Doesn't implement references that involve range unions and lists (but does implement
|
103
103
|
standard ranges)\n5. Sometimes gives cells as being empty, when excel would give
|
104
104
|
the cell as having a numeric value of zero\n6. The generated C version does not
|
105
|
-
multithread and will give bad results if you try\n7.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
multithread and will give bad results if you try\n7. The generated code uses floating
|
106
|
+
point, rather than fully precise arithmetic, so results can differ slightly\n8.
|
107
|
+
The generated code uses the sprintf approach to rounding (even-odd) rather than
|
108
|
+
excel's 0.5 rounds away from zero.\n90. Ranges like this: Sheet1!A10:Sheet1!B20
|
109
|
+
and 3D ranges don't work\n"
|
110
110
|
email: tamc@greenonblack.com
|
111
111
|
executables:
|
112
112
|
- excel_to_c
|