summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJurriaan Pruis <[email protected]>2012-04-01 15:49:13 +0200
committerJurriaan Pruis <[email protected]>2012-04-01 15:49:13 +0200
commit24079401c00af3b000644a57b82627556deea596 (patch)
treefea7bcb547bf523ecb74ee20f90816a824f29350
parent16f19d36a774a578f4a6892caab320dd262b8e71 (diff)
downloadcaxlsx-24079401c00af3b000644a57b82627556deea596.tar.gz
caxlsx-24079401c00af3b000644a57b82627556deea596.zip
Skip cells with nil values
-rw-r--r--examples/example.rb3
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/examples/example.rb b/examples/example.rb
index 04ad6f4c..d93f5dcc 100644
--- a/examples/example.rb
+++ b/examples/example.rb
@@ -266,7 +266,8 @@ end
wb.add_worksheet(:name => "custom column widths") do |sheet|
sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
- sheet.column_widths nil, 3
+ sheet.add_row ['abcdefg', 'This is a very long text and should flow into the right cell', nil, 'xxx' ]
+ sheet.column_widths nil, 3, 5, nil
end
##Fit to page printing
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index cb8dd61b..48e77e31 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -310,6 +310,7 @@ module Axlsx
# @param [String] str The string index the cell content will be appended to. Defaults to empty string.
# @return [String] xml text for the cell
def to_xml_string(r_index, c_index, str = '')
+ return str if @value.nil?
str << '<c r="' << Axlsx::cell_r(c_index, r_index) << '" s="' << @style.to_s << '" '
case @type
when :string
@@ -398,6 +399,7 @@ module Axlsx
elsif @type == :boolean
v ? 1 : 0
else
+ return nil if v.nil?
@type = :string
::CGI.escapeHTML(v.to_s)
end