class Xlsxrb::WorksheetBuilder::Snapshot
The state of a sheet when its block ended: the worksheet without its rows, the pending rows, and the hyperlinks and comments to attach to their cells.
@api private
Attributes
column_style_clocks
[R]
Hash[Integer, Integer]
The style log clock when each column’s style was set.
frame
[R]
Elements::Worksheet
The worksheet with every part except its rows.
rows
[R]
Array[PendingRow]
Public Class Methods
(Elements::Worksheet frame, Array[PendingRow] rows, Hash[String, untyped] hyperlinks, Hash[String, untyped] comments, Hash[String, Array[untyped]] threaded_comments, Hash[Integer, Integer] column_style_clocks) → void
Source
# File lib/xlsxrb/worksheet_builder.rb, line 2000 def initialize(frame, rows, hyperlinks, comments, threaded_comments, column_style_clocks) @frame = frame @rows = rows @column_style_clocks = column_style_clocks @hyperlinks = hyperlinks @comments = comments @threaded_comments = threaded_comments @links = !(hyperlinks.empty? && comments.empty? && threaded_comments.empty?) end
Public Instance Methods
(Array[Elements::Cell] cells) → Array[Elements::Cell]
Source
# File lib/xlsxrb/worksheet_builder.rb, line 2019 def attach_links(cells) return cells unless @links cells.map do |cell| hl = @hyperlinks[cell.ref] cm = @comments[cell.ref] tcs = @threaded_comments[cell.ref] if hl || cm || tcs cell.with( hyperlink: hl || cell.hyperlink, comment: cm || cell.comment, threaded_comments: (tcs ? (cell.threaded_comments + tcs) : cell.threaded_comments) ) else cell end end end
Attaches the sheet’s hyperlinks and comments to the cells they refer to.
(?Array[Elements::Row]? rows, ?Array[Elements::Column]? columns) → Elements::Worksheet
Source
# File lib/xlsxrb/worksheet_builder.rb, line 2012 def worksheet(rows = nil, columns = nil) rows ||= @rows.map { |row| row.to_row(attach_links(row.named_cells), row.style) } @frame.with(rows: rows, columns: columns || @frame.columns, errors: nil) end
Returns the worksheet with rows, or with the rows’ named cells by default.