class Xlsxrb::StreamWriter::WorksheetProxy
Proxy object yielded by the sheet method to prevent writing to inactive sheets in streaming mode.
Public Class Methods
(untyped writer, untyped sheet_name) → untyped
Source
# File lib/xlsxrb/stream_writer.rb, line 292 def initialize(writer, sheet_name) @writer = writer @sheet_name = sheet_name end
@param writer [StreamWriter] @param sheet_name [String]
Public Instance Methods
(Array[untyped] | Hash[untyped, untyped] values) → self
Source
# File lib/xlsxrb/stream_writer.rb, line 429 def <<(values) row(values) self end
Appends a row to the worksheet and returns self for chaining.
@example
sheet << ["A", 1] << ["B", 2]
@param values [Array, Hash] Row cell values. @return [self] @api public
(String expression, ?ref: String?, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), **untyped attrs) → Elements::Formula
Source
# File lib/xlsxrb/stream_writer.rb, line 316 def array_formula(...) Xlsxrb.array_formula(...) end
Creates an array or dynamic array {Elements::Formula} object. @api public
() → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 587 def auto_filter raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.auto_filter end
Returns the auto-filter range on the active sheet, or nil if none.
@return [String, nil] @api public
(String? range) → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 599 def auto_filter=(range) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.auto_filter = range end
Sets the auto-filter range on the active sheet.
@param range [String, nil] The cell range (e.g. “A1:D10”). @return [String, nil] @api public
() → Elements::BackgroundImage?
Source
# File lib/xlsxrb/stream_writer.rb, line 1251 def background_image @writer.background_image end
Gets the worksheet background image (<picture>).
@return [Elements::BackgroundImage, nil] @api public
(untyped val) → untyped
Source
# File lib/xlsxrb/stream_writer.rb, line 1263 def background_image=(val) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.background_image = val end
Sets the worksheet background image (<picture>).
@param val [String, Hash, Elements::Image, nil] Image binary data, or a Hash with :data and
+:ext+. A String is always the image itself: to use a file, pass its bytes, as in
+{ data: File.binread(path), ext: "jpg" }+.
@return [untyped] @api public
(String | Symbol | Elements::CellError code) → Elements::CellError
Source
# File lib/xlsxrb/stream_writer.rb, line 337 def cell_error(...) Xlsxrb.cell_error(...) end
Creates or returns an {Elements::CellError} object. @api public
(String ref) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1368 def cell_watch(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.cell_watch(...) end
Adds a cell watch to the sheet.
@param ref [String] Cell reference (e.g. “A1”). @return [void] @api public
(?Symbol | String? type, **untyped options) ?{ (ChartBuilder) → void } → void
Source
# File lib/xlsxrb/stream_writer.rb, line 554 def chart(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.chart(...) end
Adds a chart to the active sheet.
@example
s.chart(:bar) do |chart_builder| chart_builder.title = "Quarterly Sales" chart_builder.series(values: "Sheet1!$B$2:$B$5", categories: "Sheet1!$A$2:$A$5", name: "Revenue") end
@param type [Symbol, String, nil] The chart type (:bar, :col, :line, :pie, :scatter, :area, :doughnut, :radar). @param options [Hash] Additional chart options. @yield [chart_builder] @yieldparam chart_builder [Xlsxrb::ChartBuilder] @return [void] @api public
() → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 1422 def code_name @writer.code_name end
Gets the internal code name of the worksheet.
@return [String, nil] @api public
(String | Symbol | nil val) → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 1432 def code_name=(val) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.code_name = val end
Sets the internal code name of the worksheet.
@param val [String, Symbol, nil] The code name. @return [String, nil] @api public
(Integer | String | Symbol | Range[Integer | String | Symbol] | Array[Integer | String | Symbol] index, ?width: Float | Integer | nil, ?hidden: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool, ?style: (Integer | Symbol | String | Hash[Symbol, untyped])?, ?best_fit: bool) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 465 def column(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.column(...) end
Configures column width and properties.
@example Set column A width
s.column(0, width: 25.0)
@param index [Integer, String, Symbol, Range, Array] 0-based column index, letter (“A”, :A), range, or array. @param width [Float, Integer, nil] Column width in characters. @param hidden [Boolean] Whether the column is hidden. @param custom_width [Boolean] Whether to flag as custom width. @param outline_level [Integer, nil] Grouping/outline level (0 - 7). @param collapsed [Boolean] Whether the outline group is collapsed. @param style [Integer, Symbol, String, Hash, nil] Column style format or index. @param best_fit [Boolean] Whether the column automatically fits content. @return [void] @api public
(Integer | String | Symbol col) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1340 def column_break(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.column_break(...) end
simplecov:disable Edge case / untested delegation block Adds a vertical page break after the given column.
@param col [Integer, String, Symbol] 0-based column index or column letter. @return [void] @api public
() → Array[Elements::Column]
Source
# File lib/xlsxrb/stream_writer.rb, line 1222 def columns raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.columns end
Returns column configurations defined for this worksheet.
@return [Array<Elements::Column>] @api public
(String | Integer cell, String text, ?author: String, ?visible: bool) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 738 def comment(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.comment(...) end
Adds a comment to a cell.
@example
s.comment("A1", "Reviewed and approved", author: "Auditor")
@param cell [String, Integer] The cell reference (e.g. “A1”). @param text [String] The comment text. @param author [String] The author name. @param visible [Boolean] Whether the comment is always shown instead of on hover. @return [void] @api public
(?String? sqref, ?type: String | Symbol, **untyped opts) ?{ (ConditionalFormatBuilder) → void } → void
Source
# File lib/xlsxrb/stream_writer.rb, line 693 def conditional_format(sqref = nil, **opts, &) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.conditional_format(sqref, **opts, &) end
Adds conditional formatting to a range.
@example Highlight values greater than 100
s.conditional_format("A1:A10", type: "cellIs", operator: "greaterThan", formula: 100, style: :highlight)
@example Hierarchical differential format (dxf)
s.conditional_format("B2:B20", type: :cell_is, operator: "equal", formula: "0", dxf: { font: { bold: false, color: { auto: true } }, fill: { pattern: "none", bg_color: "FFFF00" } })
@param sqref [String, nil] The cell range (e.g. “A1:A10”). @param type [String, Symbol, nil] Rule type (“cellIs”, “colorScale”, “dataBar”, “expression”). @param opts [Hash] Rule options. @option opts [Hash] :dxf Hierarchical differential format specification. @option opts [Integer] :format_id Pre-registered differential format index (dxfId). @yield [conditional_format_builder] Optional block for configuration. @return [void] @api public
(?String? range, ?type: (String | Symbol)?, **untyped opts) ?{ (DataValidationBuilder) → void } → void
Source
# File lib/xlsxrb/stream_writer.rb, line 669 def data_validation(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.data_validation(...) end
Adds data validation rules to a range.
@example Dropdown list validation
s.data_validation("B2:B100", type: "list", formula1: '"High,Medium,Low"')
@example Block syntax
s.data_validation("B2:B100") do |dv| dv.type = :list dv.formula1 = '"High,Medium,Low"' end
@param range [String, nil] The cell range (e.g. “B2:B10”). @param type [String, Symbol, nil] Validation type (“list”, “whole”, “decimal”, “date”, “time”, “textLength”, “custom”). @param opts [Hash] Validation options. @yield [data_validation_builder] Optional configuration block. @return [void] @api public
(String name, ?untyped value, ?hidden: bool, ?columns: untyped, ?rows: untyped, ?range: untyped, ?sheet: String?, ?scope: (String | Symbol)?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 879 def defined_name(name, value = nil, hidden: false, columns: nil, rows: nil, range: nil, sheet: nil, scope: nil) raise inactive_sheet_error if @writer.current_sheet != @sheet_name ref_sheet = sheet || @sheet_name local_sheet = if scope scope == :workbook ? nil : scope.to_s end @writer.defined_name(name, value, sheet: ref_sheet, scope: local_sheet, hidden: hidden, columns: columns, rows: rows, range: range) end
Adds a defined name (named range or formula) scoped to this sheet or workbook. Bare cell references and coordinate keywords are automatically formatted with sheet quotes and absolute $ references.
@param name [String] Defined name identifier. @param value [Object, nil] Value or formula expression. @param hidden [Boolean] Whether the defined name is hidden. @param columns [Integer, String, nil] Column index or letter for coordinate-based reference. @param rows [Integer, Range, nil] Row or row range (0-based) for coordinate-based reference. @param range [String, nil] Cell range reference. @param sheet [String, nil] Reference sheet name (defaults to current sheet). @param scope [String, Symbol, nil] Scope identifier (:workbook or sheet name). @return [void] @api public
(Integer | String | Symbol col_id, (Hash[untyped, untyped] | Array[untyped]) filter) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 615 def filter_column(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.filter_column(...) end
Sets filter criteria for a column in the auto-filter.
@example Simple values filter
s.filter_column(0, ["Active", "Pending"])
@param col_id [Integer, String, Symbol] 0-based column index relative to auto-filter range or column letter. @param filter [Hash] Values or filter specification hash. @return [void] @api public
(bool? enabled) → bool??
Source
# File lib/xlsxrb/stream_writer.rb, line 1453 def fit_to_page=(enabled) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.fit_to_page = enabled end
Sets whether page setup fits content to page width/height.
@param enabled [Boolean, nil] Whether to fit to page. @return [Boolean] @api public
() → bool
Source
# File lib/xlsxrb/stream_writer.rb, line 1443 def fit_to_page? @writer.fit_to_page? end
Returns whether page setup fits content to page width/height.
@return [Boolean] @api public
(String expression, ?cached_value: (String | Numeric | bool | Elements::CellError | nil), ?type: (Symbol | String)?, ?ref: String?, ?shared_index: Integer?) → Elements::Formula
Source
# File lib/xlsxrb/stream_writer.rb, line 309 def formula(...) Xlsxrb.formula(...) end
Creates an {Elements::Formula} object. @api public
() → Elements::FreezePane?
(?row: Integer | nil, ?column: (Integer | String)?, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 906 def freeze_pane(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.freeze_pane(...) end
Configures or queries freeze panes (<pane state=“frozen”>).
When called with no arguments, returns the {Elements::FreezePane} value object or nil. When called with arguments, configures the freeze pane and returns nil.
@example Freeze top row
s.freeze_pane(row: 1)
@example Freeze first column and top 2 rows
s.freeze_pane(row: 2, column: 1)
@param row [Integer, nil] Number of rows to freeze. @param column [Integer, String, nil] Number of columns to freeze. @return [Elements::FreezePane, nil, void] @api public
(Elements::FreezePane | Hash[Symbol, untyped] | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 918 def freeze_pane=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.freeze_pane = opts end
Sets or clears freeze pane configuration.
@param opts [Elements::FreezePane, Hash, nil] Freeze pane options. @return [void] @api public
(Integer | String | Range[Integer | String] | Array[Integer | String] index, ?level: Integer, ?collapsed: bool, ?hidden: bool, ?width: Float | Integer | nil, ?style: untyped) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 482 def group_columns(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.group_columns(...) end
Groups multiple columns together with outline hierarchy.
@param index [Integer, String, Range, Array] Column index, letter, range, or array. @param level [Integer] Grouping outline level (1 to 7). @param collapsed [Boolean] Whether the group is collapsed. @param hidden [Boolean] Whether the columns are hidden. @param width [Float, Integer, nil] Optional column width. @param style [Integer, Symbol, String, nil] Optional column style. @return [void] @api public
(?untyped rows, ?level: Integer, ?collapsed: bool, ?hidden: bool) ?{ (self) → void } → void
Source
# File lib/xlsxrb/stream_writer.rb, line 498 def group_rows(rows = nil, level: 1, collapsed: false, hidden: false) raise inactive_sheet_error if @writer.current_sheet != @sheet_name if block_given? @writer.group_rows(rows, level: level, collapsed: collapsed, hidden: hidden) do yield self end else @writer.group_rows(rows, level: level, collapsed: collapsed, hidden: hidden) end end
Groups multiple rows with outline hierarchy with a block.
@param rows [Range, Array, Integer, nil] Unused in streaming write. @param level [Integer] Grouping outline level (1 to 7). @param collapsed [Boolean] Whether the group is collapsed. @param hidden [Boolean] Whether the rows are hidden. @yield Optional block executed with active group outline settings. @return [void] @api public
(String | Integer cell, ?(String | Elements::Hyperlink)? url, ?display: String?, ?tooltip: String?, ?location: String?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 576 def hyperlink(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.hyperlink(...) end
Adds a hyperlink to a cell.
@example Positional URL
s.hyperlink("A1", "https://example.com", display: "Example")
@example Keyword location
s.hyperlink("A1", location: "https://example.com", tooltip: "Go to Example")
@param cell [String] The cell reference (e.g. “A1”). @param url [String, nil] The target URL or URI. @param display [String, nil] Display text for the link. @param tooltip [String, nil] Tooltip text when hovering. @param location [String, nil] Destination location / URL (keyword alternative). @return [void] @api public
(String sqref, ?eval_error: bool, ?two_digit_text_year: bool, ?number_stored_as_text: bool, ?formula: bool, ?formula_range: bool, ?unlocked_formula: bool, ?empty_cell_reference: bool, ?list_data_validation: bool, ?calculated_column: bool) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1381 def ignored_error(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.ignored_error(...) end
Adds an ignored error entry to the sheet.
@param sqref [String] Cell range reference (e.g. “A1” or “A1:B10”). @param opts [Hash] Error check flags to ignore. @return [void] @api public
() → Array[Elements::IgnoredError]
Source
# File lib/xlsxrb/stream_writer.rb, line 1392 def ignored_errors @writer.ignored_errors end
Returns the ignored error entries configured for this sheet.
@return [Array<Elements::IgnoredError>] @api public
(String file_data, ?ext: String, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1240 def image(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.image(...) end
Inserts an image into the sheet.
@param file_data [String] Binary image data or file content. @param ext [String] Image extension (“png”, “jpeg”, etc.). @param from_column [Integer, nil] Starting column index (0-based). @param from_row [Integer] Starting row index (0-based). @param to_column [Integer, nil] Ending column index (0-based). @param to_row [Integer] Ending row index (0-based). @param opts [Hash] Additional anchor and sizing options. @return [void] @api public
(String range) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 368 def merge(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.merge(...) end
Merges a range of cells into a single cell.
@example Merge with cell reference string
s.merge("A1:C1")
@param range [String] The cell range (e.g. “A1:B2”). @return [void] @api public
() → String
Source
# File lib/xlsxrb/stream_writer.rb, line 302 def name @sheet_name end
Returns the worksheet name.
@return [String] @api public
() → Hash[Symbol, untyped]
(?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, ?apply_styles: bool?, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 521 def outline_properties(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.outline_properties(...) end
Configures or queries worksheet-level outline and grouping view properties.
@param summary_below [Boolean, nil] Summary rows below detail rows. @param summary_right [Boolean, nil] Summary columns to the right of detail columns. @param show_outline_symbols [Boolean, nil] Outline symbols visible. @param apply_styles [Boolean, nil] Automatic styles applied. @param opts [Hash] Additional options. @return [Hash<Symbol, untyped>, void] @api public
(Hash[Symbol, untyped] opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 533 def outline_properties=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.outline_properties = opts end
Sets worksheet-level outline and grouping view properties.
@param opts [Hash] Outline properties. @return [void] @api public
() → Elements::PageMargins?
(?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1088 def page_margins(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.page_margins(...) end
Configures or queries page margins for printing (<pageMargins>).
When called with no arguments, returns the {Elements::PageMargins} value object or nil. When called with arguments, configures page margins and returns nil.
@param left [Float, nil] Left margin in inches. @param right [Float, nil] Right margin in inches. @param top [Float, nil] Top margin in inches. @param bottom [Float, nil] Bottom margin in inches. @param header [Float, nil] Header margin in inches. @param footer [Float, nil] Footer margin in inches. @return [Elements::PageMargins, nil, void] @api public
(Hash[Symbol, untyped] | Elements::PageMargins | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1100 def page_margins=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.page_margins = opts end
Sets or clears page margins configuration.
@param opts [Hash, Elements::PageMargins, nil] @return [void] @api public
() → Elements::PageSetup
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1118 def page_setup(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.page_setup(...) end
Configures or queries page orientation, paper size, and print setup (<pageSetup>).
When called with no arguments, returns the {Elements::PageSetup} value object. When called with keyword arguments, updates page setup and returns nil.
@param orientation [String, Symbol, nil] “portrait” or “landscape” (or :portrait, :landscape). @param paper_size [Integer, nil] Paper size index (e.g. 9 for A4, 1 for Letter). @param opts [Hash] Additional options (scale, fit_to_width, fit_to_height). @return [Elements::PageSetup, void] @api public
(Hash[Symbol, untyped] | Elements::PageSetup opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1130 def page_setup=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.page_setup = opts end
Sets page setup configuration.
@param opts [Hash, Elements::PageSetup] @return [void] @api public
() → Elements::PhoneticProperties?
Source
# File lib/xlsxrb/stream_writer.rb, line 1401 def phonetic_properties @writer.phonetic_properties end
Gets phonetic (furigana) guide properties for the sheet.
@return [Elements::PhoneticProperties, nil] @api public
(Hash[Symbol, untyped] | Integer | nil spec) → (Hash[Symbol, untyped] | Integer | nil)
Source
# File lib/xlsxrb/stream_writer.rb, line 1411 def phonetic_properties=(spec) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.phonetic_properties = spec end
Sets phonetic (furigana) guide properties for the sheet.
@param spec [Hash, Integer, nil] Options hash or font ID integer. @return [Hash[Symbol, untyped], Integer, nil] @api public
(String source_ref, row_fields: untyped, data_fields: untyped, ?column_fields: untyped, ?ref: String?, ?name: String?, ?field_names: untyped, ?items: untyped, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 773 def pivot_table(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.pivot_table(...) end
Adds a Pivot Table to the sheet.
@param source_ref [String] Source data range reference (e.g. “Sheet1!A1:D100”). @param row_fields [Array<String>] Field names for rows. @param data_fields [Array<String>] Field names for data values. @param column_fields [Array<String>, nil] Field names for columns. @param ref [String, nil] Target top-left cell reference (default: “E1”). @param name [String, nil] Pivot table name. @param field_names [Array<String>, nil] Override field names. @param items [Hash{Integer => Array}, nil] Items of each field, by 0-based field index. @param opts [Hash] Additional options. @return [void] @api public
() → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 929 def print_area @writer.print_area(sheet: @sheet_name) end
Returns the print area range for this worksheet, or nil if none.
@return [String, nil] @api public
(String? range) → String?
Source
# File lib/xlsxrb/stream_writer.rb, line 939 def print_area=(range) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.send(:set_print_area, range, sheet: @sheet_name) end
Sets the print area for this worksheet.
@param range [String, nil] Cell range (e.g. “A1:G50”). @return [String, nil] @api public
() → Elements::PrintOptions
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1172 def print_options(**opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.print_options(**opts) end
Configures or gets print options (e.g. gridlines, headings). Configures or queries print options.
@param opts [Hash] Additional options. @return [Elements::PrintOptions, void] @api public
(Hash[Symbol, untyped] | Elements::PrintOptions opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1183 def print_options=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.print_options = opts end
Replaces print options. @param opts [Hash, Elements::PrintOptions] @return [void] @api public
() → Elements::PrintTitles?
(?rows: (String | Integer | Range[Integer])?, ?columns: (String | Integer | Symbol | Range[untyped])?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 956 def print_titles(rows: nil, columns: nil) raise inactive_sheet_error if @writer.current_sheet != @sheet_name if rows.nil? && columns.nil? @writer.print_titles(sheet: @sheet_name) else @writer.print_titles(rows: rows, columns: columns, sheet: @sheet_name) end end
Sets or gets repeating print titles (rows and/or columns) for pagination.
When called with no arguments, returns the {Elements::PrintTitles} value object or nil. When called with arguments, updates print titles and returns nil.
@param rows [String, Integer, Range, nil] Repeating row range (e.g. “1:2”). @param columns [String, Integer, Symbol, Range, nil] Repeating column range (e.g. “A:B”). @return [Elements::PrintTitles, nil, void] @api public
(Elements::PrintTitles | Hash[Symbol, untyped] | nil opts) → (Elements::PrintTitles | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/stream_writer.rb, line 972 def print_titles=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name if opts.nil? @writer.print_titles = nil else h = opts.respond_to?(:to_h) ? opts.to_h : opts @writer.print_titles(**h, sheet: @sheet_name) end opts end
Sets repeating print titles for this worksheet.
@param opts [Elements::PrintTitles, Hash, nil] Options with :rows and/or :columns. @return [Elements::PrintTitles, Hash, nil] @api public
(String name, String sqref, ?password: String?, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1356 def protected_range(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.protected_range(...) end
Adds a protected range to the sheet.
@param name [String] Name of the protected range. @param sqref [String] Cell range (e.g. “A1:B10”). @param password [String, nil] Optional password or hash. @param opts [Hash] Additional options. @return [void] @api public
(Integer | String first, ?(Integer | String)? last) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1004 def repeat_columns(first, last = nil) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.repeat_columns(first, last, sheet: @sheet_name) end
Sets repeating title columns to appear at the left of each printed page.
@param first [Integer, String] First column index (0-based) or column name/range. @param last [Integer, String, nil] Optional last column index/name. @return [void] @api public
(Integer | String first, ?(Integer | String)? last) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 991 def repeat_rows(first, last = nil) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.repeat_rows(first, last, sheet: @sheet_name) end
Sets repeating title rows to appear at the top of each printed page.
@param first [Integer, String] First row index (0-based) or range string (e.g. “1:2”). @param last [Integer, String, nil] Optional last row index (0-based). @return [void] @api public
(*(Hash[Symbol, untyped] | Elements::RichTextRun | String | Array[untyped] | untyped) runs, ?text: String?, ?base_font: untyped, **untyped font_props) → Elements::RichText
Source
# File lib/xlsxrb/stream_writer.rb, line 330 def rich_text(...) Xlsxrb.rich_text(...) end
Creates an {Elements::RichText} object. @api public
(Array[untyped] | Hash[untyped, untyped] values, ?cell_styles: untyped, ?row_style: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?collapsed: bool, ?outline_level: Integer | nil) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 414 def row(values, cell_styles: nil, row_style: nil, height: nil, hidden: false, custom_height: false, collapsed: false, outline_level: nil) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.row(values, cell_styles: cell_styles, row_style: row_style, height: height, hidden: hidden, custom_height: custom_height, collapsed: collapsed, outline_level: outline_level) end
Appends a row of cells to the active sheet.
@example Write an array of values
s.row(["Name", "Age", "City"])
@example Write with explicit column keys and styles
s.row({ A: "Header", C: 100 }, cell_styles: { A: :bold })
@param values [Array, Hash] The cell values (e.g. ‘[1, 2, 3]` or `{ A: 1, C: 3 }`). @param cell_styles [String, Symbol, Array, Hash, nil] Style names or hashes to apply to cells. @param row_style [Integer, Symbol, String, Hash, nil] Row style format or index. @param height [Float, Integer, nil] The row height in points (0 - 409). @param hidden [Boolean] Whether the row is hidden. @param custom_height [Boolean] Whether to flag as custom height. @param outline_level [Integer, nil] Grouping/outline level (0 - 7). @param collapsed [Boolean] Whether the row is collapsed. @return [void] @api public
(Integer row_index) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1325 def row_break(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.row_break(...) end
simplecov:disable Edge case / untested delegation block Adds a horizontal page break after the given row index.
@param row_index [Integer] 0-based row index. @return [void] @api public
() → (Elements::Selection | Array[Elements::Selection])?
(?String? active_cell, ?sqref: String?, ?pane: (String | Symbol)?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1055 def selection(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.selection(...) end
Sets or queries the active/selected cell on the sheet (<selection>).
When called with no arguments, returns the selection ({Elements::Selection}, Array, or nil). When called with arguments, updates the selection and returns nil.
@param active_cell [String, nil] Cell reference (e.g. “A1”) or range (e.g. “A1:D10”). @param sqref [String, nil] Selection range. @param pane [String, Symbol, nil] Pane identifier. @return [Elements::Selection, Array<Elements::Selection>, nil, void] @api public
(Elements::Selection | Array[Elements::Selection | Hash[Symbol, untyped]] | Hash[Symbol, untyped] | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1067 def selection=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.selection = opts end
Sets or clears the selection configuration.
@param opts [Elements::Selection, Array<Elements::Selection, Hash>, Hash, nil] @return [void] @api public
(?preset: String, ?text: String?, ?from_column: Integer?, ?from_row: Integer, ?to_column: Integer?, ?to_row: Integer, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 389 def shape(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.shape(...) end
Adds a drawing shape to the sheet.
@example
s.shape(preset: "ellipse", text: "Circle", from_column: 1, from_row: 1, to_column: 4, to_row: 5)
@param preset [String] Preset shape type (e.g. “rect”, “ellipse”). @param text [String, nil] Shape label text. @param from_column [Integer, nil] Starting column index (0-based). @param from_row [Integer] Starting row index (0-based). @param to_column [Integer, nil] Ending column index (0-based). @param to_row [Integer] Ending row index (0-based). @param opts [Hash] Additional shape formatting options. @return [void] @api public
() → Elements::SheetCalcProperties?
Source
# File lib/xlsxrb/stream_writer.rb, line 1464 def sheet_calc_properties @writer.sheet_calc_properties end
Gets worksheet calculation properties (<sheetCalcPr>).
@return [Elements::SheetCalcProperties, nil] @api public
(Hash[Symbol, untyped]? spec) → Hash[Symbol, untyped]?
Source
# File lib/xlsxrb/stream_writer.rb, line 1474 def sheet_calc_properties=(spec) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_calc_properties = spec end
Sets worksheet calculation properties (<sheetCalcPr>).
@param spec [Hash, nil] Calculation properties hash. @return [Hash, nil] @api public
() → Elements::SheetFormat
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1300 def sheet_format(**opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_format(**opts) end
Configures or gets sheet format properties (e.g. default_row_height, default_column_width).
@param opts [Hash] Keyword arguments for sheet format properties. @return [Elements::SheetFormat, void] @api public
(Hash[Symbol, untyped] | Elements::SheetFormat opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1311 def sheet_format=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_format = opts end
Replaces sheet format properties. @param opts [Hash, Elements::SheetFormat] @return [void] @api public
() → Elements::SheetProperties
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 848 def sheet_properties(**opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_properties(**opts) end
Configures or queries sheet properties.
@param opts [Hash] Keyword options for sheet properties. @return [Elements::SheetProperties, void] @api public
(Hash[Symbol, untyped] | Elements::SheetProperties opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 859 def sheet_properties=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_properties = opts end
Replaces worksheet properties. @param opts [Hash, Elements::SheetProperties] @return [void] @api public
() → Elements::SheetProtection?
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1199 def sheet_protection(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_protection(...) end
Sets or queries sheet-level protection with optional password hashing (<sheetProtection>).
When called with no arguments, returns the {Elements::SheetProtection} value object or nil. When called with keyword arguments, sets sheet protection and returns nil.
@param opts [Hash] Protection options. @return [Elements::SheetProtection, nil, void] @api public
(Elements::SheetProtection | Hash[Symbol, untyped] | bool | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1211 def sheet_protection=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_protection = opts end
Sets or clears sheet protection configuration.
@param opts [Elements::SheetProtection, Hash, Boolean, nil] @return [void] @api public
() → Elements::SheetView
(**untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1276 def sheet_view(**opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_view(**opts) end
Configures or gets sheet view settings (zoom scale, grid lines visibility).
@param opts [Hash] Additional options. @return [Elements::SheetView, void] @api public
(Hash[Symbol, untyped] | Elements::SheetView opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1287 def sheet_view=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sheet_view = opts end
Replaces sheet view properties. @param opts [Hash, Elements::SheetView] @return [void] @api public
(?Integer count) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 443 def skip_rows(count = 1) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.skip_rows(count) end
Advances the row cursor by count without writing empty row elements.
@example Skip multiple rows
s.skip_rows(3)
@param count [Integer] Number of rows to skip (must be >= 1). @return [void] @api public
() → Elements::SortState?
(?String? ref, ?Array[Hash[untyped, untyped]]? sort_conditions, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 633 def sort_state(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sort_state(...) end
Configures or queries sort state on a range.
When called with no arguments, returns the {Elements::SortState} value object. When called with arguments, updates sort state and returns nil.
@param ref [String, nil] The range to sort. @param sort_conditions [Array<Hash>, nil] Sort conditions array. @param opts [Hash] Additional sort options. @return [Elements::SortState, nil, void] @api public
(Elements::SortState | Hash[Symbol, untyped] | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 645 def sort_state=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sort_state = opts end
Sets sort state configuration for the active sheet.
@param opts [Elements::SortState, Hash, nil] Sort state options. @return [void] @api public
(sparklines: Array[Hash[Symbol, untyped]], ?type: (String | Symbol)?, **untyped opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 790 def sparkline_group(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.sparkline_group(...) end
Adds sparklines to the sheet.
@example
s.sparkline_group(sparklines: [{ data_ref: "A1:E1", location_ref: "F1" }], type: "line")
@param sparklines [Array<Hash>] Array of { data_ref:, location_ref: } hashes. @param type [String, Symbol, nil] “line” (default), “column”, or “stacked”. @param opts [Hash] Additional sparkline options. @return [void] @api public
() → Elements::SplitPane?
(?x_split: Integer | nil, ?y_split: Integer | nil, ?top_left_cell: String?, ?active_pane: (String | Symbol)?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1025 def split_pane(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.split_pane(...) end
Splits sheet view into panes or queries split pane settings (<pane>).
When called with no arguments, returns the {Elements::SplitPane} value object or nil. When called with arguments, configures the split pane and returns nil.
@param x_split [Integer, nil] Horizontal split position. @param y_split [Integer, nil] Vertical split position. @param top_left_cell [String, nil] Top-left visible cell in bottom-right pane. @param active_pane [String, Symbol, nil] Active pane identifier. @param state [String, Symbol, nil] Split state. @return [Elements::SplitPane, nil, void] @api public
(Elements::SplitPane | Hash[Symbol, untyped] | nil opts) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 1037 def split_pane=(opts) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.split_pane = opts end
Sets or clears split pane configuration.
@param opts [Elements::SplitPane, Hash, nil] Split pane options. @return [void] @api public
() → Symbol
Source
# File lib/xlsxrb/stream_writer.rb, line 803 def state @writer.state end
Sets workbook-level properties.
Gets the sheet visibility state (:visible, :hidden, or :very_hidden).
@return [Symbol] @api public
(Symbol | String new_state) → Symbol
Source
# File lib/xlsxrb/stream_writer.rb, line 813 def state=(new_state) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.state = new_state @writer.state end
Sets the sheet visibility state (:visible, :hidden, or :very_hidden).
@param new_state [Symbol, String] The new state. @return [Symbol] @api public
(String | Symbol name, **untyped opts) ?{ (Xlsxrb::StyleBuilder) → void } → Xlsxrb::StyleBuilder
Source
# File lib/xlsxrb/stream_writer.rb, line 353 def style(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.style(...) end
Defines or configures a named cell style on the active sheet.
@example
s.style(:header, bold: true, fill_color: "4F81BD", font_color: "FFFFFF")
@param name [String, Symbol] The name of the style. @param opts [Hash] Style options (e.g. bold: true, fill_color: “FF0000”). @yield [style_builder] @yieldparam style_builder [Xlsxrb::StyleBuilder] @return [Xlsxrb::StyleBuilder] @api public
() → (String | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/stream_writer.rb, line 825 def tab_color @writer.tab_color end
Gets the tab color of this worksheet.
@return [String, Hash, nil] @api public
(String | Symbol | Hash[Symbol, untyped] | nil spec) → (String | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/stream_writer.rb, line 835 def tab_color=(spec) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.tab_color = spec end
Sets the tab color of this worksheet.
@param spec [String, Hash, Symbol, nil] Tab color hex string or hash options. @return [String, Hash, nil] @api public
(?String? ref, ?columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) ?{ (TableBuilder) → void } → void
Source
# File lib/xlsxrb/stream_writer.rb, line 720 def table(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.table(...) end
Adds a formatted Excel Table to the sheet.
@example Standard keyword arguments
s.table("A1:C10", columns: ["ID", "Name", "Total"], name: "SalesTable", style: "TableStyleMedium9")
@example Block syntax
s.table("A1:C10") do |t| t.columns = ["ID", "Name", "Total"] t.style = "TableStyleMedium9" end
@param ref [String, nil] The cell range for the table (e.g. “A1:D10”). @param columns [Array<String>, Array<Hash>, nil] Column names or definitions. @param name [String, nil] Table name. @param display_name [String, nil] Display name. @param style [String, nil] Table style name. @param opts [Hash] Additional options. @yield [table_builder] Optional configuration block. @return [void] @api public
(String | Integer cell, String text, ?author: untyped, ?timestamp: untyped, ?id: String?, ?parent_id: String?, ?done: bool?, ?user_id: String?, ?provider_id: String?) → void
Source
# File lib/xlsxrb/stream_writer.rb, line 753 def threaded_comment(...) raise inactive_sheet_error if @writer.current_sheet != @sheet_name @writer.threaded_comment(...) end
Adds a threaded comment to a cell.
@param cell [String, Integer] The cell reference (e.g. “A1”). @param text [String] The comment text. @param author [String] The author name. @param visible [Boolean] Whether the comment is always shown instead of on hover. # @param opts [Hash] Options: timestamp, id, parent_id, done, user_id, provider_id. @return [void] @api public