From 24079401c00af3b000644a57b82627556deea596 Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Sun, 1 Apr 2012 15:49:13 +0200 Subject: Skip cells with nil values --- examples/example.rb | 3 ++- lib/axlsx/workbook/worksheet/cell.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 << '