class Xlsxrb::WorksheetBuilder::PendingRow
A row as given to {WorksheetBuilder#row}, kept until the workbook resolves its style names, so that its cells are created once.
@api private
Attributes
Integer
The style log clock when the row was added: its styles are the definitions made before.
untyped
bool
untyped
Number format codes of the cells’ sheet styles: an Array, one code, or nil.
(Float | Integer)?
Integer
Integer?
untyped
The row style as given: a name, an index, an inline Hash, or nil.
untyped
Style of each cell: a name, an index, or nil; or one of these for every cell.
Array[untyped]
Cell values; Hashes with :formula and rich text runs are already converted.
Integer
Number of columns the row spans, including styled cells past the last value.
Public Class Methods
(Integer row_index, Integer column_index, untyped value, untyped style, String? format_code, bool valid_coordinates) → Elements::Cell
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1968 def self.cell(row_index, column_index, value, style, format_code, valid_coordinates) formula = nil if value.is_a?(Elements::Formula) formula = value value = formula.cached_value valid_coordinates &&= Elements::Cell.valid_value?(value) end raw_value = value&.to_s if valid_coordinates && !style.is_a?(Integer) Elements::Cell.fast_create(row_index, column_index, value, style, formula, raw_value, format_code) else Elements::Cell.new(row_index: row_index, column_index: column_index, value: value, formula: formula, style: style, raw_value: raw_value, format_code: format_code) end end
Creates a cell for value with style (a name, an index, or nil). valid_coordinates tells whether the cell is within Excel’s limits; a valid cell has no errors, so it skips the checks of Cell.new.
(Integer index, Array[untyped] values, untyped styles, untyped format_codes, Integer width, (Float | Integer)? height, untyped hidden, bool custom_height, untyped collapsed, Integer? outline_level, untyped style, Integer clock) → void
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1900 def initialize(index, values, styles, format_codes, width, height, hidden, custom_height, collapsed, outline_level, style, clock) @index = index @values = values @styles = styles @format_codes = format_codes @width = width @height = height @hidden = hidden @custom_height = custom_height @collapsed = collapsed @outline_level = outline_level @style = style @clock = clock end
Public Instance Methods
() → Array[Elements::Cell]
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1928 def named_cells values = @values styles = @styles codes = @format_codes style_lookup = styles.is_a?(Array) code_lookup = codes.is_a?(Array) all_valid = within_limits? cells = [] #: Array[Elements::Cell] col_index = 0 while col_index < @width value = col_index < values.size ? values[col_index] : nil style = style_lookup ? styles[col_index] : styles unless value.nil? && style.nil? code = code_lookup ? codes[col_index] : codes cells << PendingRow.cell(@index, col_index, value, style, code, all_valid || Elements::Cell.valid_coordinates?(@index, col_index)) end col_index += 1 end cells end
Returns the row’s cells with their style names, as {WorksheetBuilder#build} gives them.
(Array[Elements::Cell] cells, untyped style_index) → Elements::Row
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1950 def to_row(cells, style_index) Elements::Row.new( index: @index, cells: cells, height: @height, hidden: @hidden, custom_height: @custom_height, collapsed: @collapsed, outline_level: @outline_level, style_index: style_index, unmapped_data: Elements::EMPTY_HASH ) end
(hidden: untyped, collapsed: untyped, outline_level: Integer?) → PendingRow
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1916 def with_outline(hidden:, collapsed:, outline_level:) PendingRow.new(@index, @values, @styles, @format_codes, @width, @height, hidden, @custom_height, collapsed, outline_level, @style, @clock) end
() → bool
Source
# File lib/xlsxrb/worksheet_builder.rb, line 1922 def within_limits? Elements::Cell.valid_coordinates?(@index, 0) && @width <= 16_384 end
Returns whether every cell of the row is within Excel’s row and column limits.