summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-06-02 23:52:32 +0900
committerRandy Morgan <[email protected]>2012-06-02 23:52:32 +0900
commit376d60eebeb0a48579862004d8a70b00fb39ee32 (patch)
tree55cb871b87d6903819ab6a7ef56eaba02940d5c7
parent2786ef5f7fc3a97403b69f530114860a19aa5fee (diff)
downloadcaxlsx-376d60eebeb0a48579862004d8a70b00fb39ee32.tar.gz
caxlsx-376d60eebeb0a48579862004d8a70b00fb39ee32.zip
more work on solidifying parsing of data caching for charts to eliminate formula strings.
-rw-r--r--README.md2
-rw-r--r--lib/axlsx/drawing/num_data.rb4
-rw-r--r--lib/axlsx/drawing/num_val.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb4
-rw-r--r--test/drawing/tc_num_data.rb6
5 files changed, 14 insertions, 4 deletions
diff --git a/README.md b/README.md
index 38c760ea..48f501ba 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,8 @@ The example listing is getting overly large to maintain here.
If you are using Yard, you will be able to see the examples in line below.
If not, please refer to the Please see the {file:examples/example.rb} file.
+![examples](https://github.com/randym/axlsx/raw/master/examples/examples.rb)
+
{include:file:examples/example.rb}
There is much, much more you can do with this gem. If you get stuck, grab me on IRC or submit an issue to GitHub. Chances are that it has already been implemented. If it hasn't - let's take a look at adding it in.
diff --git a/lib/axlsx/drawing/num_data.rb b/lib/axlsx/drawing/num_data.rb
index 802a0216..ee6b145e 100644
--- a/lib/axlsx/drawing/num_data.rb
+++ b/lib/axlsx/drawing/num_data.rb
@@ -25,8 +25,8 @@ module Axlsx
def data=(values=[])
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
values.each do |value|
- v = value.is_a?(Cell) ? value.value : value
- @pt << NumVal.new(:v => v)
+ value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
+ @pt << NumVal.new(:v => value)
end
end
diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb
index 35dbdb83..ed655732 100644
--- a/lib/axlsx/drawing/num_val.rb
+++ b/lib/axlsx/drawing/num_val.rb
@@ -26,7 +26,7 @@ module Axlsx
# serialize the object
def to_xml_string(idx, str = "")
Axlsx::validate_unsigned_int(idx)
- str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s.to_i.to_s << '</c:v></c:pt>'
+ str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>'
end
end
end
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index 745809f9..e3e153e0 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -317,6 +317,10 @@ module Axlsx
str << '</c>'
end
+ def is_formula?
+ @type == :string && @value.start_with('=')
+ end
+
private
# Utility method for setting inline style attributes
diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb
index 85bf5614..2549af4d 100644
--- a/test/drawing/tc_num_data.rb
+++ b/test/drawing/tc_num_data.rb
@@ -9,7 +9,11 @@ class TestNumData < Test::Unit::TestCase
def test_initialize
assert_equal(@num_data.format_code, "General")
end
-
+
+ def test_formula_based_cell
+
+ end
+
def test_format_code
assert_raise(ArgumentError) {@num_data.format_code = 7}
assert_nothing_raised {@num_data.format_code = 'foo_bar'}