diff options
| author | Jurriaan Pruis <[email protected]> | 2014-03-05 18:25:45 +0100 |
|---|---|---|
| committer | Jurriaan Pruis <[email protected]> | 2014-03-05 18:25:45 +0100 |
| commit | 7771d1b7103385718818883e332255cf7fc6d876 (patch) | |
| tree | 70417b59a72b3c00b425a5cf90947902d704fe65 | |
| parent | e98a148ddd741001a2ec952712135b233ee51491 (diff) | |
| parent | 85512559e72e886de3cac15345655f37a633945e (diff) | |
| download | caxlsx-7771d1b7103385718818883e332255cf7fc6d876.tar.gz caxlsx-7771d1b7103385718818883e332255cf7fc6d876.zip | |
Merge pull request #297 from jurriaan/small-fixes
Small fixes & cleanup
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 10 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell_serializer.rb | 9 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 10 |
3 files changed, 12 insertions, 17 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 3ecc73d7..46391229 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -47,9 +47,7 @@ module Axlsx parse_options(options) self.value = value - if value.is_a?(RichText) - value.cell = self - end + value.cell = self if contains_rich_text? end # this is the cached value for formula cells. If you want the values to render in iOS/Mac OSX preview @@ -436,8 +434,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? - return v if v.is_a? RichText + return v if v.is_a?(RichText) || v.nil? case type when :date self.style = STYLE_DATE if self.style == 0 @@ -457,8 +454,7 @@ module Axlsx else # TODO find a better way to do this as it accounts for 30% of # processing time in benchmarking... - - Axlsx::trust_input ? v.to_s : ::CGI.escapeHTML(Axlsx::sanitize(v.to_s)) + Axlsx::trust_input ? v.to_s : Axlsx::sanitize(::CGI.escapeHTML(v.to_s)) end end diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index 81ae11de..73b7c110 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -3,8 +3,6 @@ module Axlsx # The Cell Serializer class contains the logic for serializing cells based on their type. class CellSerializer class << self - - # Calls the proper serialization method based on type. # @param [Integer] row_index The index of the cell's row # @param [Integer] column_index The index of the cell's column @@ -18,7 +16,6 @@ module Axlsx str << '</c>' end - # builds an xml text run based on this cells attributes. # @param [String] str The string instance this run will be concated to. # @return [String] @@ -44,7 +41,6 @@ module Axlsx value_serialization 'd', cell.value, str end - # serializes cells that are type date # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. @@ -85,7 +81,6 @@ module Axlsx numeric cell, str end - # Serializes cells that are type formula # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. @@ -130,6 +125,10 @@ module Axlsx end end + # Serializes cells that are of the type richtext + # @param [Cell] cell The cell that is being serialized + # @param [String] str The string the serialized content will be appended to. + # @return [String] def richtext(cell, str) if cell.ssti.nil? inline_string_serialization cell, str diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index a2d58562..96fbf959 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -442,10 +442,10 @@ module Axlsx # @option options [Array] widths each member of the widths array will affect how auto_fit behavies. # @option options [Float] height the row's height (in points) def add_row(values=[], options={}) - Row.new(self, values, options) - update_column_info @rows.last, options.delete(:widths) - yield @rows.last if block_given? - @rows.last + row = Row.new(self, values, options) + update_column_info row, options.delete(:widths) + yield row if block_given? + row end alias :<< :add_row @@ -597,7 +597,7 @@ module Axlsx add_autofilter_defined_name_to_workbook str << '<sheet ' serialized_attributes str - str << ("r:id='" << rId << '\'></sheet>') + str << ('r:id="' << rId << '"></sheet>') end # Serializes the worksheet object to an xml string |
