Class: Xlsxrb::StreamWriter::WorksheetProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxrb.rb,
sig/generated/xlsxrb.rbs

Overview

Proxy object yielded by the sheet method to prevent writing to inactive sheets.

Instance Method Summary collapse

Constructor Details

#initialize(writer, sheet_name) ⇒ WorksheetProxy

Returns a new instance of WorksheetProxy.

Parameters:

  • writer (Object)
  • sheet_name (Object)


1686
1687
1688
1689
# File 'lib/xlsxrb.rb', line 1686

def initialize(writer, sheet_name)
  @writer = writer
  @sheet_name = sheet_name
end

Instance Method Details

#app_propertyvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Set app metadata property.

: (String | Symbol name, untyped value) -> void

Parameters:

  • name (String, Symbol)

    Property name.

  • value (Object)

    Property value.



2289
2290
2291
2292
2293
# File 'lib/xlsxrb.rb', line 2289

def app_property(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.app_property(...)
end

#auto_filtervoid

This method returns an undefined value.

Set the auto-filter range on the sheet.

: (String ref) -> void

Examples:

s.auto_filter("A1:D100")

Parameters:

  • ref (String)

    The cell range (e.g. "A1:D10").



1859
1860
1861
1862
1863
# File 'lib/xlsxrb.rb', line 1859

def auto_filter(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.auto_filter(...)
end

#chart {|chart_builder| ... } ⇒ void

This method returns an undefined value.

Add a chart to the sheet.

: (?Symbol | String? type, **untyped opts) ?{ (Xlsxrb::ChartBuilder) -> void } -> void

Examples:

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

Parameters:

  • type (Symbol, String, nil)

    The chart type (:bar, :col, :line, :pie, :scatter, :area, :doughnut, :radar).

  • opts (Hash)

    Additional chart options.

Yields:

  • (chart_builder)

Yield Parameters:



1822
1823
1824
1825
1826
# File 'lib/xlsxrb.rb', line 1822

def chart(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.chart(...)
end

#cleanup!void

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block : () -> void



1961
1962
1963
1964
1965
# File 'lib/xlsxrb.rb', line 1961

def cleanup!(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.cleanup!(...)
end

#columnvoid

This method returns an undefined value.

Configure column width and properties.

: (Integer | String | Symbol col_index, ?width: Float | Integer | nil, ?hidden: bool, ?best_fit: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool) -> void

Examples:

Set column A width

s.column(0, width: 25.0)

Parameters:

  • col_index (Integer, String, Symbol)

    0-based column index or letter (e.g. 0 or "A" or :A).

  • width (Float, Integer, nil)

    Column width in characters.

  • hidden (Boolean)

    Whether the column is hidden.

  • best_fit (Boolean)

    Whether the column automatically fits content.

  • custom_width (Boolean)

    Whether to flag as custom width.

  • outline_level (Integer, nil)

    Grouping/outline level (0 - 7).

  • collapsed (Boolean)

    Whether the outline group is collapsed.

  • width: (Float, Integer, nil)
  • hidden: (Boolean)
  • best_fit: (Boolean)
  • custom_width: (Boolean)
  • outline_level: (Integer, nil)
  • collapsed: (Boolean)


1801
1802
1803
1804
1805
# File 'lib/xlsxrb.rb', line 1801

def column(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.column(...)
end

#commentvoid

This method returns an undefined value.

Add a comment to a cell.

: (String | Integer cell, String text, ?author: String) -> void

Examples:

s.comment("A1", "Reviewed and approved", author: "Auditor")

Parameters:

  • cell (String, Integer)

    The cell reference (e.g. "A1").

  • text (String)

    The comment text.

  • author (String)

    The author name.

  • author: (String)


1979
1980
1981
1982
1983
# File 'lib/xlsxrb.rb', line 1979

def comment(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.comment(...)
end

#conditional_formatvoid

This method returns an undefined value.

Add conditional formatting to a range.

: (String range, ?type: String | Symbol, **untyped opts) -> void

Examples:

Highlight values greater than 100

s.conditional_format("A1:A10", type: "cellIs", operator: "greaterThan", formula: 100, style: :highlight)

Parameters:

  • range (String)

    The cell range (e.g. "A1:A10").

  • type (String, Symbol)

    Rule type ("cellIs", "colorScale", "dataBar", "expression").

  • opts (Hash)

    Rule options.

  • type: (String, Symbol)


1932
1933
1934
1935
1936
# File 'lib/xlsxrb.rb', line 1932

def conditional_format(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.conditional_format(...)
end

#core_propertyvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Set core metadata property.

: (String | Symbol name, untyped value) -> void

Parameters:

  • name (String, Symbol)

    Property name.

  • value (Object)

    Property value.



2167
2168
2169
2170
2171
# File 'lib/xlsxrb.rb', line 2167

def core_property(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.core_property(...)
end

#custom_propertyvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Set custom metadata property.

: (String | Symbol name, untyped value) -> void

Parameters:

  • name (String, Symbol)

    Property name.

  • value (Object)

    Property value.



2320
2321
2322
2323
2324
# File 'lib/xlsxrb.rb', line 2320

def custom_property(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.custom_property(...)
end

#defined_namevoid

This method returns an undefined value.

Add a defined named range or formula.

: (String name, String formula, ?sheet_id: Integer | nil, ?hidden: bool) -> void

Examples:

s.defined_name("TaxRate", "0.10")

Parameters:

  • name (String)

    The name.

  • formula (String)

    The formula or range expression.

  • sheet_id (Integer, nil)

    Optional sheet scope.

  • hidden (Boolean)

    Whether the name is hidden.

  • sheet_id: (Integer, nil)
  • hidden: (Boolean)


2065
2066
2067
2068
2069
# File 'lib/xlsxrb.rb', line 2065

def defined_name(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.defined_name(...)
end

#filter_columnvoid

This method returns an undefined value.

Set filter criteria for a column in the auto-filter.

: (Integer col_id, Array | Hash[Symbol, untyped] filter_values) -> void

Examples:

Simple values filter

s.filter_column(0, ["Active", "Pending"])

Custom filter specification

s.filter_column(0, { type: :filters, values: ["Data"] })

Parameters:

  • col_id (Integer)

    0-based column index relative to auto-filter range.

  • filter_values (Array<String>, Hash)

    Values or filter specification hash.



1878
1879
1880
1881
1882
# File 'lib/xlsxrb.rb', line 1878

def filter_column(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.filter_column(...)
end

#freeze_panevoid

This method returns an undefined value.

Freeze rows and/or columns for scrolling.

: (?row: Integer | nil, ?col: Integer | nil) -> void

Examples:

Freeze top row

s.freeze_pane(row: 1)

Freeze first column and top 2 rows

s.freeze_pane(row: 2, col: 1)

Parameters:

  • row (Integer, nil)

    Number of rows to freeze.

  • col (Integer, nil)

    Number of columns to freeze.

  • row: (Integer, nil)
  • col: (Integer, nil)


2084
2085
2086
2087
2088
# File 'lib/xlsxrb.rb', line 2084

def freeze_pane(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.freeze_pane(...)
end

This method returns an undefined value.

Configure header and footer text for printing.

: (**untyped opts) -> void

Examples:

s.header_footer(odd_header: "&CConfidential", odd_footer: "&RPage &P of &N")

Parameters:

  • opts (Hash)

    Header and footer specifications.



2238
2239
2240
2241
2242
# File 'lib/xlsxrb.rb', line 2238

def header_footer(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.header_footer(...)
end

This method returns an undefined value.

Add a hyperlink to a cell.

: (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void

Examples:

Positional URL

s.hyperlink("A1", "https://example.com", display: "Example")

Keyword location

s.hyperlink("A1", location: "https://example.com", tooltip: "Go to Example")

Parameters:

  • cell (String)

    The cell reference (e.g. "A1").

  • url (String, nil)

    The target URL or URI.

  • display (String, nil)

    Display text for the link.

  • tooltip (String, nil)

    Tooltip text when hovering.

  • location (String, nil)

    Destination location / URL (keyword alternative).

  • display: (String, nil)
  • tooltip: (String, nil)
  • location: (String, nil)


1844
1845
1846
1847
1848
# File 'lib/xlsxrb.rb', line 1844

def hyperlink(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.hyperlink(...)
end

#imagevoid

This method returns an undefined value.

Insert an image into the sheet.

: (String file_data, ?ext: String, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void

Examples:

s.image(File.read("logo.png"), ext: "png", from_col: 0, from_row: 0, to_col: 2, to_row: 3)

Parameters:

  • file_data (String)

    Binary image data or file content.

  • ext (String)

    Image extension ("png", "jpeg", etc.).

  • from_col (Integer)

    Starting column index (0-based).

  • from_row (Integer)

    Starting row index (0-based).

  • to_col (Integer)

    Ending column index (0-based).

  • to_row (Integer)

    Ending row index (0-based).

  • opts (Hash)

    Additional anchor and sizing options.

  • ext: (String)
  • from_col: (Integer)
  • from_row: (Integer)
  • to_col: (Integer)
  • to_row: (Integer)


2342
2343
2344
2345
2346
# File 'lib/xlsxrb.rb', line 2342

def image(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.image(...)
end

#internal_sheet_setupvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block : (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped

Parameters:

  • args (Object)
  • kwargs (Object)


1756
1757
1758
1759
1760
# File 'lib/xlsxrb.rb', line 1756

def internal_sheet_setup(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.internal_sheet_setup(...)
end

#mergevoid

This method returns an undefined value.

Merge a range of cells.

: (?String? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void

Examples:

Merge with cell reference string

s.merge("A1:C1")

Merge with coordinates

s.merge(row: 0, col_start: 0, col_end: 2)

Parameters:

  • range (String, nil)

    The cell range (e.g. "A1:B2").

  • row (Integer, nil)

    0-based row index.

  • col_start (Integer, String, nil)

    0-based start column index or letter.

  • col_end (Integer, String, nil)

    0-based end column index or letter.

  • row_start (Integer, nil)

    0-based start row index.

  • row_end (Integer, nil)

    0-based end row index.

  • row: (Integer, nil)
  • col_start: (Integer, String, nil)
  • col_end: (Integer, String, nil)
  • row_start: (Integer, nil)
  • row_end: (Integer, nil)


1726
1727
1728
1729
1730
# File 'lib/xlsxrb.rb', line 1726

def merge(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.merge(...)
end

#page_break_colvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Add a vertical page break after the given column index.

: (Integer col_index) -> void

Examples:

s.page_break_col(5)

Parameters:

  • col_index (Integer)

    0-based column index.



2394
2395
2396
2397
2398
# File 'lib/xlsxrb.rb', line 2394

def page_break_col(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.page_break_col(...)
end

#page_break_rowvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Add a horizontal page break after the given row index.

: (Integer row_index) -> void

Examples:

s.page_break_row(25)

Parameters:

  • row_index (Integer)

    0-based row index.



2376
2377
2378
2379
2380
# File 'lib/xlsxrb.rb', line 2376

def page_break_row(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.page_break_row(...)
end

#page_marginsvoid

This method returns an undefined value.

Configure page margins for printing.

: (?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) -> void

Examples:

s.page_margins(left: 0.7, right: 0.7, top: 0.75, bottom: 0.75)

Parameters:

  • left (Float, nil)

    Left margin in inches.

  • right (Float, nil)

    Right margin in inches.

  • top (Float, nil)

    Top margin in inches.

  • bottom (Float, nil)

    Bottom margin in inches.

  • header (Float, nil)

    Header margin in inches.

  • footer (Float, nil)

    Footer margin in inches.

  • left: (Float, nil)
  • right: (Float, nil)
  • top: (Float, nil)
  • bottom: (Float, nil)
  • header: (Float, nil)
  • footer: (Float, nil)


2206
2207
2208
2209
2210
# File 'lib/xlsxrb.rb', line 2206

def page_margins(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.page_margins(...)
end

#page_setupvoid

This method returns an undefined value.

Configure page orientation, paper size, and print setup.

: (?orientation: (String | Symbol)?, ?paper_size: Integer | nil, **untyped opts) -> void

Examples:

Landscape A4

s.page_setup(orientation: "landscape", paper_size: 9)

Parameters:

  • orientation (String, Symbol, nil)

    "portrait" or "landscape" (or :portrait, :landscape).

  • paper_size (Integer, nil)

    Paper size index (e.g. 9 for A4, 1 for Letter).

  • opts (Hash)

    Additional options (scale, fit_to_width, fit_to_height).

  • orientation: (String, Symbol, nil)
  • paper_size: (Integer, nil)


2223
2224
2225
2226
2227
# File 'lib/xlsxrb.rb', line 2223

def page_setup(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.page_setup(...)
end

#pivot_tablevoid

This method returns an undefined value.

Add a Pivot Table to the sheet.

: (String source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: String, ?name: String?, ?field_names: untyped, ?items: untyped, **untyped opts) -> void

Examples:

s.pivot_table("Sheet1!A1:D100", row_fields: ["Category"], data_fields: ["Amount"], dest_ref: "F1")

Parameters:

  • source_ref (String)

    Source data range reference (e.g. "Sheet1!A1:D100").

  • row_fields (Array<String>)

    Field names for rows.

  • data_fields (Array<String>)

    Field names for data values.

  • col_fields (Array<String>)

    Field names for columns.

  • dest_ref (String)

    Target top-left cell reference (default: "E1").

  • name (String, nil)

    Pivot table name.

  • field_names (Array<String>, nil)

    Override field names.

  • items (Array, nil)

    Items configuration.

  • opts (Hash)

    Additional options.

  • row_fields: (Object)
  • data_fields: (Object)
  • col_fields: (Object)
  • dest_ref: (String)
  • name: (String, nil)
  • field_names: (Object)
  • items: (Object)


2002
2003
2004
2005
2006
# File 'lib/xlsxrb.rb', line 2002

def pivot_table(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.pivot_table(...)
end

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Set the print area range for the sheet.

: (String ref) -> void

Examples:

s.print_area("A1:G50")

Parameters:

  • ref (String)

    Range reference.



2101
2102
2103
2104
2105
# File 'lib/xlsxrb.rb', line 2101

def print_area(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.print_area(...)
end

This method returns an undefined value.

Configure print options (e.g. gridlines, headings).

: (Symbol | String name, untyped value) -> void

Examples:

s.print_options(:grid_lines, true)

Parameters:

  • name (Symbol, String)

    Print option name.

  • value (Object)

    Print option value.



2254
2255
2256
2257
2258
# File 'lib/xlsxrb.rb', line 2254

def print_options(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.print_options(...)
end

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Configure repeating title rows and columns for printing.

: (?rows: String?, ?cols: String?) -> void

Examples:

Repeat top 2 rows on every page

s.print_titles(rows: "1:2")

Parameters:

  • rows (String, nil)

    Row range to repeat (e.g. "1:2").

  • cols (String, nil)

    Column range to repeat (e.g. "A:B").

  • rows: (String, nil)
  • cols: (String, nil)


2120
2121
2122
2123
2124
# File 'lib/xlsxrb.rb', line 2120

def print_titles(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.print_titles(...)
end

#propertiesvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Set document metadata properties (core, app, custom).

: (?core: Hash[untyped, untyped]?, ?app: Hash[untyped, untyped]?, ?custom: Hash[untyped, untyped]?) -> void

Examples:

s.properties(core: { title: "Report", creator: "App" })

Parameters:

  • core (Hash, nil)

    Core properties (title, creator, subject, etc.).

  • app (Hash, nil)

    App properties (company, manager).

  • custom (Hash, nil)

    Custom properties.

  • core: (Hash[untyped, untyped], nil)
  • app: (Hash[untyped, untyped], nil)
  • custom: (Hash[untyped, untyped], nil)


2273
2274
2275
2276
2277
# File 'lib/xlsxrb.rb', line 2273

def properties(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.properties(...)
end

#protect_sheetvoid

This method returns an undefined value.

Protect the worksheet against modifications.

: (**untyped opts) -> void

Examples:

s.protect_sheet(password: "secret", select_locked_cells: true)

Parameters:

  • opts (Hash)

    Protection options.



2305
2306
2307
2308
2309
# File 'lib/xlsxrb.rb', line 2305

def protect_sheet(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.protect_sheet(...)
end

#protect_workbookvoid

This method returns an undefined value.

simplecov:disable Edge case / untested delegation block Protect the workbook structure.

: (**untyped opts) -> void

Parameters:

  • opts (Hash)

    Protection options.



2151
2152
2153
2154
2155
# File 'lib/xlsxrb.rb', line 2151

def protect_workbook(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.protect_workbook(...)
end

#rowvoid

This method returns an undefined value.

Add a row to the active sheet.

: (Array | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void

Examples:

Write an array of values

s.row(["Name", "Age", "City"])

Write with explicit column keys and styles

s.row({ A: "Header", C: 100 }, styles: { A: :bold })

Parameters:

  • values (Array, Hash)

    The cell values (e.g. [1, 2, 3] or { A: 1, C: 3 }).

  • styles (String, Symbol, Array, Hash, nil)

    Style names or hashes to apply.

  • height (Float, Integer, nil)

    The row height in points (0 - 409).

  • hidden (Boolean)

    Whether the row is hidden.

  • custom_height (Boolean)

    Whether to flag as custom height.

  • outline_level (Integer, nil)

    Grouping/outline level (0 - 7).

  • styles: (Object)
  • height: (Float, Integer, nil)
  • hidden: (Boolean)
  • custom_height: (Boolean)
  • outline_level: (Integer, nil)


1780
1781
1782
1783
1784
# File 'lib/xlsxrb.rb', line 1780

def row(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.row(...)
end

#select_cellvoid

This method returns an undefined value.

Set the active/selected cell on the sheet.

: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void

Examples:

s.select_cell("B5")
s.select_cell("A1", sqref: "A1:A2", pane: "topRight")

Parameters:

  • active_cell (String)

    Cell reference (e.g. "A1").

  • sqref (String, nil)

    Selection range.

  • pane (String, Symbol, nil)

    Pane identifier.

  • sqref: (String, nil)
  • pane: (String, Symbol, nil)


2186
2187
2188
2189
2190
# File 'lib/xlsxrb.rb', line 2186

def select_cell(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.select_cell(...)
end

#shapevoid

This method returns an undefined value.

Add a drawing shape to the sheet.

: (?preset: String, ?text: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void

Examples:

s.shape(preset: "ellipse", text: "Circle", from_col: 1, from_row: 1, to_col: 4, to_row: 5)

Parameters:

  • preset (String)

    Preset shape type (e.g. "rect", "ellipse").

  • text (String, nil)

    Shape label text.

  • from_col (Integer)

    Starting column index (0-based).

  • from_row (Integer)

    Starting row index (0-based).

  • to_col (Integer)

    Ending column index (0-based).

  • to_row (Integer)

    Ending row index (0-based).

  • opts (Hash)

    Additional shape formatting options.

  • preset: (String)
  • text: (String, nil)
  • from_col: (Integer)
  • from_row: (Integer)
  • to_col: (Integer)
  • to_row: (Integer)


1747
1748
1749
1750
1751
# File 'lib/xlsxrb.rb', line 1747

def shape(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.shape(...)
end

#sheet_propertiesvoid

This method returns an undefined value.

Set sheet properties (e.g. tab color, page setup flags).

: (Symbol | String name, untyped value) -> void

Examples:

s.sheet_properties(:tab_color, "FF0000")

Parameters:

  • name (Symbol, String)

    Property name.

  • value (Object)

    Property value.



2047
2048
2049
2050
2051
# File 'lib/xlsxrb.rb', line 2047

def sheet_properties(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.sheet_properties(...)
end

#sheet_viewvoid

This method returns an undefined value.

Configure sheet view settings (zoom scale, grid lines visibility).

: (Symbol | String name, untyped value) -> void

Examples:

s.sheet_view(:show_grid_lines, false)
s.sheet_view(:zoom_scale, 120)

Parameters:

  • name (Symbol, String)

    View setting name.

  • value (Object)

    View setting value.



2359
2360
2361
2362
2363
# File 'lib/xlsxrb.rb', line 2359

def sheet_view(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.sheet_view(...)
end

#sort_statevoid

This method returns an undefined value.

Configure sort state on a range.

: (String ref, Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped] sort_conditions, **untyped opts) -> void

Examples:

s.sort_state("A1:A10", [{ ref: "A1:A10", descending: true }])

Parameters:

  • ref (String)

    The range to sort.

  • sort_conditions (Array<Hash>, Hash)

    Sort conditions array or options hash.

  • opts (Hash)

    Additional sort options.



1895
1896
1897
1898
1899
# File 'lib/xlsxrb.rb', line 1895

def sort_state(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.sort_state(...)
end

#sparkline_groupvoid

This method returns an undefined value.

Add sparklines to the sheet.

: (sparklines: Array[Hash[Symbol, untyped]], ?type: String?, **untyped opts) -> void

Examples:

s.sparkline_group(sparklines: [{ data_ref: "A1:E1", location_ref: "F1" }], type: "line")

Parameters:

  • sparklines (Array<Hash>)

    Array of { data_ref:, location_ref: } hashes.

  • type (String, nil)

    "line" (default), "column", or "stacked".

  • opts (Hash)

    Additional sparkline options.

  • sparklines: (Array[Hash[Symbol, untyped]])
  • type: (String, nil)


2019
2020
2021
2022
2023
# File 'lib/xlsxrb.rb', line 2019

def sparkline_group(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.sparkline_group(...)
end

#split_panevoid

This method returns an undefined value.

Split sheet view into panes.

: (?x_split: Numeric | nil, ?y_split: Numeric | nil, ?top_left_cell: String?, ?active_pane: String?, ?state: String?) -> void

Parameters:

  • x_split (Numeric, nil)

    Horizontal split position.

  • y_split (Numeric, nil)

    Vertical split position.

  • top_left_cell (String, nil)

    Top-left visible cell in bottom-right pane.

  • active_pane (String, nil)

    Active pane identifier.

  • state (String, nil)

    Split state.

  • x_split: (Numeric, nil)
  • y_split: (Numeric, nil)
  • top_left_cell: (String, nil)
  • active_pane: (String, nil)
  • state: (String, nil)


2137
2138
2139
2140
2141
# File 'lib/xlsxrb.rb', line 2137

def split_pane(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.split_pane(...)
end

#style {|style_builder| ... } ⇒ Xlsxrb::StyleBuilder

Define or configure a named cell style.

: (String | Symbol name, **untyped opts) ?{ (Xlsxrb::StyleBuilder) -> void } -> Xlsxrb::StyleBuilder

Examples:

s.style(:header, bold: true, fill_color: "4F81BD", font_color: "FFFFFF")

Parameters:

  • name (String, Symbol)

    The name of the style.

  • opts (Hash)

    Style options (e.g. bold: true, fill_color: "FF0000").

Yields:

  • (style_builder)

Yield Parameters:

Returns:



1703
1704
1705
1706
1707
# File 'lib/xlsxrb.rb', line 1703

def style(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.style(...)
end

#tablevoid

This method returns an undefined value.

Add a formatted Excel Table to the sheet.

: (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void

Examples:

s.table("A1:C10", columns: ["ID", "Name", "Total"], name: "SalesTable", style: "TableStyleMedium9")

Parameters:

  • ref (String)

    The cell range for the table (e.g. "A1:D10").

  • columns (Array<String>, Array<Hash>)

    Column names or definitions.

  • name (String, nil)

    Table name.

  • display_name (String, nil)

    Display name.

  • style (String, nil)

    Table style name.

  • opts (Hash)

    Additional options.

  • columns: (Object)
  • name: (String, nil)
  • display_name: (String, nil)
  • style: (String, nil)


1952
1953
1954
1955
1956
# File 'lib/xlsxrb.rb', line 1952

def table(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.table(...)
end

#validate_datavoid

This method returns an undefined value.

Add data validation rules to a range.

: (String range, ?type: String | Symbol, **untyped opts) -> void

Examples:

Dropdown list validation

s.validate_data("B2:B100", type: "list", formula1: '"High,Medium,Low"')

Integer range validation

s.validate_data("C2:C100", type: "whole", operator: "between", formula1: 1, formula2: 100)

Parameters:

  • range (String)

    The cell range (e.g. "B2:B10").

  • type (String, Symbol)

    Validation type ("list", "whole", "decimal", "date", "time", "textLength", "custom").

  • opts (Hash)

    Validation options.

  • type: (String, Symbol)


1915
1916
1917
1918
1919
# File 'lib/xlsxrb.rb', line 1915

def validate_data(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.validate_data(...)
end

#workbook_propertyvoid

This method returns an undefined value.

Set workbook-level properties.

: (**untyped opts) -> void

Parameters:

  • opts (Hash)

    Workbook property options.



2031
2032
2033
2034
2035
# File 'lib/xlsxrb.rb', line 2031

def workbook_property(...)
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name

  @writer.workbook_property(...)
end