From 5a567dd9fad7cb4739c92d2dda3faba8d50225b6 Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Sun, 1 Apr 2012 15:48:08 +0200 Subject: Fixed formula handling --- lib/axlsx/workbook/worksheet/cell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 13140786..cb8dd61b 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -315,7 +315,7 @@ module Axlsx when :string #parse formula if @value.start_with?('=') - str << 't="str">' << value.to_s.gsub('=', '') << '' + str << 't="str">' << @value.to_s.gsub('=', '') << '' else #parse shared if @ssti -- cgit v1.2.3 From 16f19d36a774a578f4a6892caab320dd262b8e71 Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Sun, 1 Apr 2012 15:48:37 +0200 Subject: String table ignore nil values --- lib/axlsx/workbook/shared_strings_table.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index dac8221f..332a4470 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -29,7 +29,7 @@ module Axlsx # Creates a new Shared Strings Table agains an array of cells # @param [Array] cells This is an array of all of the cells in the workbook def initialize(cells) - cells = cells.flatten.reject { |c| c.type != :string || c.value.start_with?('=') } + cells = cells.flatten.reject { |c| c.type != :string || c.value.nil? || c.value.start_with?('=') } @count = cells.size @unique_cells = [] @shared_xml_string = "" -- cgit v1.2.3 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(-) (limited to 'lib') 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 << ' Date: Mon, 2 Apr 2012 13:48:14 +0200 Subject: Support nil cells for all types --- lib/axlsx/workbook/worksheet/cell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 48e77e31..6f90dfa7 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -386,6 +386,7 @@ module Axlsx # About Time - Time in OOXML is *different* from what you might expect. The history as to why is interesting, but you can safely assume that if you are generating docs on a mac, you will want to specify Workbook.1904 as true when using time typed values. # @see Axlsx#date1904 def cast_value(v) + return nil if v.nil? if @type == :date self.style = STYLE_DATE if self.style == 0 v @@ -399,7 +400,6 @@ module Axlsx elsif @type == :boolean v ? 1 : 0 else - return nil if v.nil? @type = :string ::CGI.escapeHTML(v.to_s) end -- cgit v1.2.3