lib/axlsx/workbook/worksheet/row.rb in axlsx-1.1.3 vs lib/axlsx/workbook/worksheet/row.rb in axlsx-1.1.4

- old
+ new

@@ -3,10 +3,11 @@ # A Row is a single row in a worksheet. # @note The recommended way to manage rows and cells is to use Worksheet#add_row # @see Worksheet#add_row class Row + SERIALIZABLE_ATTRIBUTES = [:hidden, :outlineLevel, :collapsed, :style] # The worksheet this row belongs to # @return [Worksheet] attr_reader :worksheet # The cells this row holds @@ -15,17 +16,33 @@ # The height of this row in points, if set explicitly. # @return [Float] attr_reader :height + # Flag indicating if the outlining of the affected column(s) is in the collapsed state. + # @return [Boolean] + attr_reader :collapsed + + # Flag indicating if the affected column(s) are hidden on this worksheet. + # @return [Boolean] + attr_reader :hidden + + # Outline level of affected column(s). Range is 0 to 7. + # @return [Integer] + attr_reader :outlineLevel + + # Default style for the affected column(s). Affects cells not yet allocated in the column(s). In other words, this style applies to new columns. + # @return [Integer] + attr_reader :style + # TODO 18.3.1.73 - # collapsed + # # collapsed # customFormat - # hidden - # outlineLevel + # # hidden + # # outlineLevel # ph - # s (style) + # # s (style) # spans # thickTop # thickBottom @@ -51,10 +68,29 @@ @worksheet.rows << self self.height = options.delete(:height) if options[:height] array_to_cells(values, options) end + # @see Row#collapsed + def collapsed=(v) + Axlsx.validate_boolean(v) + @collapsed = v + end + + # @see Row#hidden + def hidden=(v) + Axlsx.validate_boolean(v) + @hidden = v + end + + # @see Row#outline + def outlineLevel=(v) + Axlsx.validate_unsigned_numeric(v) + @outlineLevel = v + end + + # The index of this row in the worksheet # @return [Integer] def index worksheet.rows.index(self) end @@ -63,10 +99,13 @@ # @param [Integer] r_index The row index, 0 based. # @param [String] str The string this rows xml will be appended to. # @return [String] def to_xml_string(r_index, str = '') str << '<row r="' << (r_index + 1 ).to_s << '" ' + instance_values.select { |key, value| SERIALIZABLE_ATTRIBUTES.include? key.to_sym }.each do |key, value| + str << key << '="' << value.to_s << '" ' + end if custom_height? str << 'customHeight="1" ht="' << height.to_s << '">' else str << '>' end @@ -77,10 +116,10 @@ # Adds a singel sell to the row based on the data provided and updates the worksheet's autofit data. # @return [Cell] def add_cell(value="", options={}) c = Cell.new(self, value, options) - worksheet.send(:update_column_info, self.cells, self.cells.map(&:style)) + worksheet.send(:update_column_info, self.cells, [], self.cells.map(&:style)) c end # sets the style for every cell in this row def style=(style)