lib/axlsx/workbook/worksheet/row.rb in axlsx-1.0.18 vs lib/axlsx/workbook/worksheet/row.rb in axlsx-1.1.0

- old
+ new

@@ -58,23 +58,30 @@ def index worksheet.rows.index(self) end # Serializes the row - # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. + # @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(xml) - attrs = {:r => index+1} - attrs.merge!(:customHeight => 1, :ht => height) if custom_height? - xml.row(attrs) { |ixml| @cells.each { |cell| cell.to_xml(ixml) } } + def to_xml_string(r_index, str = '') + str << '<row r="' << (r_index + 1 ).to_s << '" ' + if custom_height? + str << 'customHeight="1" ht="' << height.to_s << '">' + else + str << '>' + end + @cells.each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, str) } + str << '</row>' + str end # 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) - update_auto_fit_data + 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) @@ -103,16 +110,9 @@ private # assigns the owning worksheet for this row def worksheet=(v) DataTypeValidator.validate "Row.worksheet", Worksheet, v; @worksheet=v; end - - # Tell the worksheet to update autofit data for the columns based on this row's cells. - # @return [SimpleTypedList] - def update_auto_fit_data - worksheet.send(:update_auto_fit_data, self.cells) - end - # Converts values, types, and style options into cells and associates them with this row. # A new cell is created for each item in the values array. # If value option is defined and is a symbol it is applied to all the cells created. # If the value option is an array, cell types are applied by index for each cell