xlsxrb 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/xlsxrb.rb CHANGED
@@ -341,11 +341,17 @@ module Xlsxrb
341
341
 
342
342
  # Creates a Formula object for use in row values.
343
343
  #
344
- # @param expression [String] The formula text (e.g. "SUM(A1:A10)").
344
+ # @example Create a basic sum formula
345
+ # formula = Xlsxrb.formula("SUM(A1:A10)")
346
+ #
347
+ # @example Create a formula with precomputed cached value
348
+ # formula = Xlsxrb.formula("A1+B1", cached_value: 42)
349
+ #
350
+ # @param expression [String] The formula text without '=' (e.g. "SUM(A1:A10)").
345
351
  # @param cached_value [Object, nil] Optional cached result. If nil, Excel will calculate on open.
346
352
  # @return [Elements::Formula]
347
353
  # @api public
348
- #: (String expression, ?cached_value: String | Numeric | bool | nil) -> untyped
354
+ #: (String expression, ?cached_value: String | Numeric | bool | nil) -> Elements::Formula
349
355
  def self.formula(expression, cached_value: nil)
350
356
  Elements::Formula.new(
351
357
  expression: expression,
@@ -354,12 +360,20 @@ module Xlsxrb
354
360
  )
355
361
  end
356
362
 
357
- # Reads an XLSX file into an Elements::Workbook.
363
+ # Reads an XLSX file into an in-memory Elements::Workbook.
364
+ #
365
+ # @example Read from file path
366
+ # workbook = Xlsxrb.read("data.xlsx")
367
+ # sheet = workbook["Sheet1"]
368
+ # puts sheet["A1"].value
369
+ #
370
+ # @example Read from IO stream
371
+ # workbook = File.open("data.xlsx", "rb") { |io| Xlsxrb.read(io) }
358
372
  #
359
373
  # @param source [String, IO] File path or IO object.
360
374
  # @return [Elements::Workbook] The parsed workbook.
361
375
  # @api public
362
- #: (untyped source) -> untyped
376
+ #: (untyped source) -> Elements::Workbook
363
377
  def self.read(source)
364
378
  attributes = source.is_a?(String) ? { "filepath" => source } : {}
365
379
  Xlsxrb.in_span("Xlsxrb.read", attributes: attributes) do
@@ -382,7 +396,10 @@ module Xlsxrb
382
396
  end
383
397
  end
384
398
 
385
- # Writes an Elements::Workbook to an XLSX file.
399
+ # Writes an Elements::Workbook to an XLSX file or IO stream.
400
+ #
401
+ # @example Write to file
402
+ # Xlsxrb.write("output.xlsx", workbook)
386
403
  #
387
404
  # @param target [String, IO] File path or IO object.
388
405
  # @param workbook [Elements::Workbook] The workbook to write.
@@ -448,10 +465,10 @@ module Xlsxrb
448
465
  # The block receives an Elements::Workbook and must return a modified one (e.g. via `update_sheet`).
449
466
  # If no target is given, the source is overwritten.
450
467
  #
451
- # @example
452
- # Xlsxrb.modify("template.xlsx", "output.xlsx") do |wb|
453
- # wb.update_sheet(0) do |sheet|
454
- # sheet.update_cell("B1", value: "Updated")
468
+ # @example Modify a template and save to new file
469
+ # Xlsxrb.modify("template.xlsx", "output.xlsx") do |workbook|
470
+ # workbook.update_sheet("Sheet1") do |sheet|
471
+ # sheet.update_cell("B1", value: "Updated Title")
455
472
  # .update_cell("B2", value: 100)
456
473
  # end
457
474
  # end
@@ -463,7 +480,7 @@ module Xlsxrb
463
480
  # @yieldreturn [Elements::Workbook] The modified workbook.
464
481
  # @return [void]
465
482
  # @api public
466
- #: (untyped source, ?untyped target) ?{ (untyped) -> untyped } -> void
483
+ #: (untyped source, ?untyped target) ?{ (Elements::Workbook) -> untyped } -> void
467
484
  def self.modify(source, target = nil)
468
485
  raise Error, "source is required" if source.nil?
469
486
  raise Error, "block is required" unless block_given?
@@ -476,18 +493,38 @@ module Xlsxrb
476
493
  write(write_target, result_workbook)
477
494
  end
478
495
 
479
- # Represents a sheet being streamed sequentially.
496
+ # Represents a sheet being streamed sequentially from an XLSX file.
497
+ #
498
+ # @example Iterate rows in streaming mode
499
+ # Xlsxrb.foreach("large_data.xlsx") do |sheet|
500
+ # puts "Processing sheet: #{sheet.name}"
501
+ # sheet.each_row do |row|
502
+ # puts row.to_a.inspect
503
+ # end
504
+ # end
505
+ #
506
+ # @api public
480
507
  class StreamSheet
481
508
  [Enumerable].each { |m| include m }
482
509
 
483
510
  attr_reader :name
484
511
 
512
+ # @param name [String] The sheet name.
513
+ # @param sheet_xml [String] Raw XML content of the sheet.
514
+ # @param shared_strings [Array<String>] Shared strings table.
515
+ #: (String name, String sheet_xml, Array[String] shared_strings) -> void
485
516
  def initialize(name, sheet_xml, shared_strings)
486
517
  @name = name
487
518
  @sheet_xml = sheet_xml
488
519
  @shared_strings = shared_strings
489
520
  end
490
521
 
522
+ # Iterate over rows in this streaming sheet.
523
+ #
524
+ # @yield [row]
525
+ # @yieldparam row [Elements::Row]
526
+ # @return [Enumerator, void]
527
+ # @api public
491
528
  #: () { (Elements::Row) -> void } -> void
492
529
  #: | () -> Enumerator[Elements::Row, void]
493
530
  def each_row
@@ -502,6 +539,12 @@ module Xlsxrb
502
539
  end
503
540
  end
504
541
 
542
+ # Iterate over rows in this streaming sheet.
543
+ #
544
+ # @yield [row]
545
+ # @yieldparam row [Elements::Row]
546
+ # @return [Enumerator, void]
547
+ # @api public
505
548
  #: () { (Elements::Row) -> void } -> void
506
549
  #: | () -> Enumerator[Elements::Row, void]
507
550
  def each(&)
@@ -509,13 +552,19 @@ module Xlsxrb
509
552
  end
510
553
  end
511
554
 
512
- # Streaming read: yields StreamSheet objects one at a time for each sheet.
555
+ # Streaming read: yields StreamSheet objects one at a time for each sheet in the workbook.
556
+ # Keeps memory usage minimal even for multi-gigabyte XLSX files.
557
+ #
558
+ # @example
559
+ # Xlsxrb.foreach("large.xlsx") do |sheet|
560
+ # puts "Sheet: #{sheet.name}"
561
+ # sheet.each_row { |row| process(row) }
562
+ # end
513
563
  #
514
564
  # @param source [String, IO] File path or IO object.
515
565
  # @yield [sheet] Yields each sheet.
516
566
  # @yieldparam sheet [StreamSheet] The streaming sheet object.
517
- # @return [Enumerator] If no block is given.
518
- # @return [void]
567
+ # @return [Enumerator, void]
519
568
  # @api public
520
569
  #: (untyped source) ?{ (StreamSheet) -> void } -> untyped
521
570
  def self.foreach(source)
@@ -541,14 +590,23 @@ module Xlsxrb
541
590
  end
542
591
  end
543
592
 
544
- # Streaming write: yields a StreamWriter context for building XLSX on-the-fly.
593
+ # Streaming write: yields a StreamWriter context for high-speed, zero-allocation XLSX generation.
545
594
  #
546
- # @param target [String, IO] File path or IO object.
595
+ # @example Generate an Excel file with styles and multiple sheets
596
+ # Xlsxrb.generate("sales.xlsx") do |stream_writer|
597
+ # stream_writer.sheet("Q1") do |sheet|
598
+ # sheet.row(["Product", "Revenue"], styles: :bold)
599
+ # sheet.row(["Widget", 15000])
600
+ # end
601
+ # end
602
+ #
603
+ # @param target [String, IO] File path or IO stream (e.g. pipe, socket, Rails response buffer).
604
+ # @param strict_excel_mode [Boolean] Whether to enforce Excel specifications (max rows/cols/length).
547
605
  # @yield [stream_writer]
548
606
  # @yieldparam stream_writer [Xlsxrb::StreamWriter]
549
607
  # @return [void]
550
608
  # @api public
551
- #: (untyped target, ?strict_excel_mode: bool) ?{ (Xlsxrb::StreamWriter) -> void } -> void
609
+ #: (untyped target, ?strict_excel_mode: bool) ?{ (StreamWriter) -> void } -> void
552
610
  def self.generate(target, strict_excel_mode: true)
553
611
  raise Error, "target is required" if target.nil?
554
612
  raise Error, "block is required" unless block_given?
@@ -565,13 +623,22 @@ module Xlsxrb
565
623
  end
566
624
  end
567
625
 
568
- # Builds an Elements::Workbook in memory using a DSL.
626
+ # Builds an in-memory Elements::Workbook using a declarative DSL.
627
+ #
628
+ # @example Build in-memory workbook
629
+ # workbook = Xlsxrb.build do |builder|
630
+ # builder.sheet("Overview") do |sheet|
631
+ # sheet.row(["Title", "Date"])
632
+ # sheet.row(["Report", Date.today])
633
+ # end
634
+ # end
569
635
  #
636
+ # @param strict_excel_mode [Boolean] Whether to enforce Excel specifications.
570
637
  # @yield [builder]
571
638
  # @yieldparam builder [Xlsxrb::WorkbookBuilder]
572
639
  # @return [Elements::Workbook]
573
640
  # @api public
574
- #: (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } -> untyped
641
+ #: (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } -> Elements::Workbook
575
642
  def self.build(strict_excel_mode: true)
576
643
  raise Error, "block is required" unless block_given?
577
644
 
@@ -741,8 +808,11 @@ module Xlsxrb
741
808
  @custom_properties << { name: name, value: value, type: type }
742
809
  end
743
810
 
811
+ # Builds and returns the in-memory Elements::Workbook.
812
+ #
813
+ # @return [Elements::Workbook]
744
814
  # @api public
745
- #: () -> untyped
815
+ #: () -> Elements::Workbook
746
816
  def build
747
817
  raise ArgumentError, "Workbook must contain at least one sheet (Excel limitation)" if @strict_excel_mode && @sheets.empty?
748
818
 
@@ -1232,7 +1302,7 @@ module Xlsxrb
1232
1302
  # @param items [Array, nil] Items configuration.
1233
1303
  # @return [void]
1234
1304
  # @api public
1235
- #: (untyped source_ref, **untyped opts) -> void
1305
+ #: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
1236
1306
  def pivot_table(source_ref, row_fields:, data_fields:, col_fields: [], dest_ref: "E1", name: nil, field_names: nil, items: nil)
1237
1307
  @pivot_tables ||= []
1238
1308
  @pivot_tables << {
@@ -1266,7 +1336,7 @@ module Xlsxrb
1266
1336
  # @param opts [Hash] Additional options.
1267
1337
  # @return [void]
1268
1338
  # @api public
1269
- #: (**untyped opts) -> void
1339
+ #: (sparklines: untyped, ?type: untyped, **untyped opts) -> void
1270
1340
  def sparkline_group(sparklines:, type: nil, **opts)
1271
1341
  group = { sparklines: sparklines }
1272
1342
  group[:type] = type if type
@@ -1478,8 +1548,11 @@ module Xlsxrb
1478
1548
  @col_breaks << col_index
1479
1549
  end
1480
1550
 
1551
+ # Builds and returns the in-memory Elements::Worksheet.
1552
+ #
1553
+ # @return [Elements::Worksheet]
1481
1554
  # @api public
1482
- #: () -> untyped
1555
+ #: () -> Elements::Worksheet
1483
1556
  def build
1484
1557
  facade_meta = {}
1485
1558
  facade_meta[:hyperlinks] = @hyperlinks unless @hyperlinks.empty?
@@ -1615,439 +1688,715 @@ module Xlsxrb
1615
1688
  @sheet_name = sheet_name
1616
1689
  end
1617
1690
 
1618
- # Delegates to StreamWriter#style.
1619
- # @see StreamWriter#style
1691
+ # Define or configure a named cell style.
1692
+ #
1693
+ # @example
1694
+ # s.style(:header, bold: true, fill_color: "4F81BD", font_color: "FFFFFF")
1695
+ #
1696
+ # @param name [String, Symbol] The name of the style.
1697
+ # @param opts [Hash] Style options (e.g. bold: true, fill_color: "FF0000").
1698
+ # @yield [style_builder]
1699
+ # @yieldparam style_builder [Xlsxrb::StyleBuilder]
1700
+ # @return [Xlsxrb::StyleBuilder]
1620
1701
  # @api public
1621
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1622
- #: (*untyped args, **untyped kwargs) ?{ (Xlsxrb::StyleBuilder) -> void } -> untyped
1702
+ #: (String | Symbol name, **untyped opts) ?{ (Xlsxrb::StyleBuilder) -> void } -> Xlsxrb::StyleBuilder
1623
1703
  def style(...)
1624
1704
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1625
1705
 
1626
1706
  @writer.style(...)
1627
1707
  end
1628
1708
 
1629
- # Delegates to StreamWriter#merge.
1630
- # @see StreamWriter#merge
1709
+ # Merge a range of cells.
1710
+ #
1711
+ # @example Merge with cell reference string
1712
+ # s.merge("A1:C1")
1713
+ #
1714
+ # @example Merge with coordinates
1715
+ # s.merge(row: 0, col_start: 0, col_end: 2)
1716
+ #
1717
+ # @param range [String, nil] The cell range (e.g. "A1:B2").
1718
+ # @param row [Integer, nil] 0-based row index.
1719
+ # @param col_start [Integer, String, nil] 0-based start column index or letter.
1720
+ # @param col_end [Integer, String, nil] 0-based end column index or letter.
1721
+ # @param row_start [Integer, nil] 0-based start row index.
1722
+ # @param row_end [Integer, nil] 0-based end row index.
1723
+ # @return [void]
1631
1724
  # @api public
1632
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1725
+ #: (?String? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void
1633
1726
  def merge(...)
1634
1727
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1635
1728
 
1636
1729
  @writer.merge(...)
1637
1730
  end
1638
1731
 
1639
- # Delegates to StreamWriter#shape.
1640
- # @see StreamWriter#shape
1732
+ # Add a drawing shape to the sheet.
1733
+ #
1734
+ # @example
1735
+ # s.shape(preset: "ellipse", text: "Circle", from_col: 1, from_row: 1, to_col: 4, to_row: 5)
1736
+ #
1737
+ # @param preset [String] Preset shape type (e.g. "rect", "ellipse").
1738
+ # @param text [String, nil] Shape label text.
1739
+ # @param from_col [Integer] Starting column index (0-based).
1740
+ # @param from_row [Integer] Starting row index (0-based).
1741
+ # @param to_col [Integer] Ending column index (0-based).
1742
+ # @param to_row [Integer] Ending row index (0-based).
1743
+ # @param opts [Hash] Additional shape formatting options.
1744
+ # @return [void]
1641
1745
  # @api public
1642
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1746
+ #: (?preset: String, ?text: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
1643
1747
  def shape(...)
1644
1748
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1645
1749
 
1646
1750
  @writer.shape(...)
1647
1751
  end
1648
1752
 
1649
- # Delegates to StreamWriter#internal_sheet_setup.
1650
- # @see StreamWriter#internal_sheet_setup
1651
- # @api public
1753
+ # simplecov:disable
1754
+ # Edge case / untested delegation block
1652
1755
  #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1653
1756
  def internal_sheet_setup(...)
1654
1757
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1655
1758
 
1656
- # simplecov:disable
1657
- # Edge case / untested delegation block
1658
1759
  @writer.internal_sheet_setup(...)
1659
- # simplecov:enable
1660
1760
  end
1761
+ # simplecov:enable
1661
1762
 
1662
- # Delegates to StreamWriter#row.
1663
- # @see StreamWriter#row
1763
+ # Add a row to the active sheet.
1764
+ #
1765
+ # @example Write an array of values
1766
+ # s.row(["Name", "Age", "City"])
1767
+ #
1768
+ # @example Write with explicit column keys and styles
1769
+ # s.row({ A: "Header", C: 100 }, styles: { A: :bold })
1770
+ #
1771
+ # @param values [Array, Hash] The cell values (e.g. `[1, 2, 3]` or `{ A: 1, C: 3 }`).
1772
+ # @param styles [String, Symbol, Array, Hash, nil] Style names or hashes to apply.
1773
+ # @param height [Float, Integer, nil] The row height in points (0 - 409).
1774
+ # @param hidden [Boolean] Whether the row is hidden.
1775
+ # @param custom_height [Boolean] Whether to flag as custom height.
1776
+ # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
1777
+ # @return [void]
1664
1778
  # @api public
1665
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1779
+ #: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
1666
1780
  def row(...)
1667
1781
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1668
1782
 
1669
1783
  @writer.row(...)
1670
1784
  end
1671
1785
 
1672
- # Delegates to StreamWriter#column.
1673
- # @see StreamWriter#column
1786
+ # Configure column width and properties.
1787
+ #
1788
+ # @example Set column A width
1789
+ # s.column(0, width: 25.0)
1790
+ #
1791
+ # @param col_index [Integer, String, Symbol] 0-based column index or letter (e.g. 0 or "A" or :A).
1792
+ # @param width [Float, Integer, nil] Column width in characters.
1793
+ # @param hidden [Boolean] Whether the column is hidden.
1794
+ # @param best_fit [Boolean] Whether the column automatically fits content.
1795
+ # @param custom_width [Boolean] Whether to flag as custom width.
1796
+ # @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
1797
+ # @param collapsed [Boolean] Whether the outline group is collapsed.
1798
+ # @return [void]
1674
1799
  # @api public
1675
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1800
+ #: (Integer | String | Symbol col_index, ?width: Float | Integer | nil, ?hidden: bool, ?best_fit: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool) -> void
1676
1801
  def column(...)
1677
1802
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1678
1803
 
1679
1804
  @writer.column(...)
1680
1805
  end
1681
1806
 
1682
- # Delegates to StreamWriter#chart.
1683
- # @see StreamWriter#chart
1807
+ # Add a chart to the sheet.
1808
+ #
1809
+ # @example
1810
+ # s.chart(:bar) do |chart_builder|
1811
+ # chart_builder.title("Quarterly Sales")
1812
+ # chart_builder.series(values: "Sheet1!$B$2:$B$5", categories: "Sheet1!$A$2:$A$5", name: "Revenue")
1813
+ # end
1814
+ #
1815
+ # @param type [Symbol, String, nil] The chart type (:bar, :col, :line, :pie, :scatter, :area, :doughnut, :radar).
1816
+ # @param opts [Hash] Additional chart options.
1817
+ # @yield [chart_builder]
1818
+ # @yieldparam chart_builder [Xlsxrb::ChartBuilder]
1819
+ # @return [void]
1684
1820
  # @api public
1685
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1821
+ #: (?Symbol | String? type, **untyped opts) ?{ (Xlsxrb::ChartBuilder) -> void } -> void
1686
1822
  def chart(...)
1687
1823
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1688
1824
 
1689
1825
  @writer.chart(...)
1690
1826
  end
1691
1827
 
1692
- # Delegates to StreamWriter#hyperlink.
1693
- # @see StreamWriter#hyperlink
1828
+ # Add a hyperlink to a cell.
1829
+ #
1830
+ # @example Positional URL
1831
+ # s.hyperlink("A1", "https://example.com", display: "Example")
1832
+ #
1833
+ # @example Keyword location
1834
+ # s.hyperlink("A1", location: "https://example.com", tooltip: "Go to Example")
1835
+ #
1836
+ # @param cell [String] The cell reference (e.g. "A1").
1837
+ # @param url [String, nil] The target URL or URI.
1838
+ # @param display [String, nil] Display text for the link.
1839
+ # @param tooltip [String, nil] Tooltip text when hovering.
1840
+ # @param location [String, nil] Destination location / URL (keyword alternative).
1841
+ # @return [void]
1694
1842
  # @api public
1695
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1843
+ #: (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
1696
1844
  def hyperlink(...)
1697
1845
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1698
1846
 
1699
1847
  @writer.hyperlink(...)
1700
1848
  end
1701
1849
 
1702
- # Delegates to StreamWriter#auto_filter.
1703
- # @see StreamWriter#auto_filter
1850
+ # Set the auto-filter range on the sheet.
1851
+ #
1852
+ # @example
1853
+ # s.auto_filter("A1:D100")
1854
+ #
1855
+ # @param ref [String] The cell range (e.g. "A1:D10").
1856
+ # @return [void]
1704
1857
  # @api public
1705
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1858
+ #: (String ref) -> void
1706
1859
  def auto_filter(...)
1707
1860
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1708
1861
 
1709
1862
  @writer.auto_filter(...)
1710
1863
  end
1711
1864
 
1712
- # Delegates to StreamWriter#filter_column.
1713
- # @see StreamWriter#filter_column
1865
+ # Set filter criteria for a column in the auto-filter.
1866
+ #
1867
+ # @example Simple values filter
1868
+ # s.filter_column(0, ["Active", "Pending"])
1869
+ #
1870
+ # @example Custom filter specification
1871
+ # s.filter_column(0, { type: :filters, values: ["Data"] })
1872
+ #
1873
+ # @param col_id [Integer] 0-based column index relative to auto-filter range.
1874
+ # @param filter_values [Array<String>, Hash] Values or filter specification hash.
1875
+ # @return [void]
1714
1876
  # @api public
1715
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1877
+ #: (Integer col_id, Array[String] | Hash[Symbol, untyped] filter_values) -> void
1716
1878
  def filter_column(...)
1717
1879
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1718
1880
 
1719
1881
  @writer.filter_column(...)
1720
1882
  end
1721
1883
 
1722
- # Delegates to StreamWriter#sort_state.
1723
- # @see StreamWriter#sort_state
1884
+ # Configure sort state on a range.
1885
+ #
1886
+ # @example
1887
+ # s.sort_state("A1:A10", [{ ref: "A1:A10", descending: true }])
1888
+ #
1889
+ # @param ref [String] The range to sort.
1890
+ # @param sort_conditions [Array<Hash>, Hash] Sort conditions array or options hash.
1891
+ # @param opts [Hash] Additional sort options.
1892
+ # @return [void]
1724
1893
  # @api public
1725
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1894
+ #: (String ref, Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped] sort_conditions, **untyped opts) -> void
1726
1895
  def sort_state(...)
1727
1896
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1728
1897
 
1729
1898
  @writer.sort_state(...)
1730
1899
  end
1731
1900
 
1732
- # Delegates to StreamWriter#validate_data.
1733
- # @see StreamWriter#validate_data
1901
+ # Add data validation rules to a range.
1902
+ #
1903
+ # @example Dropdown list validation
1904
+ # s.validate_data("B2:B100", type: "list", formula1: '"High,Medium,Low"')
1905
+ #
1906
+ # @example Integer range validation
1907
+ # s.validate_data("C2:C100", type: "whole", operator: "between", formula1: 1, formula2: 100)
1908
+ #
1909
+ # @param range [String] The cell range (e.g. "B2:B10").
1910
+ # @param type [String, Symbol] Validation type ("list", "whole", "decimal", "date", "time", "textLength", "custom").
1911
+ # @param opts [Hash] Validation options.
1912
+ # @return [void]
1734
1913
  # @api public
1735
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1914
+ #: (String range, ?type: String | Symbol, **untyped opts) -> void
1736
1915
  def validate_data(...)
1737
1916
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1738
1917
 
1739
1918
  @writer.validate_data(...)
1740
1919
  end
1741
1920
 
1742
- # Delegates to StreamWriter#conditional_format.
1743
- # @see StreamWriter#conditional_format
1921
+ # Add conditional formatting to a range.
1922
+ #
1923
+ # @example Highlight values greater than 100
1924
+ # s.conditional_format("A1:A10", type: "cellIs", operator: "greaterThan", formula: 100, style: :highlight)
1925
+ #
1926
+ # @param range [String] The cell range (e.g. "A1:A10").
1927
+ # @param type [String, Symbol] Rule type ("cellIs", "colorScale", "dataBar", "expression").
1928
+ # @param opts [Hash] Rule options.
1929
+ # @return [void]
1744
1930
  # @api public
1745
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1931
+ #: (String range, ?type: String | Symbol, **untyped opts) -> void
1746
1932
  def conditional_format(...)
1747
1933
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1748
1934
 
1749
1935
  @writer.conditional_format(...)
1750
1936
  end
1751
1937
 
1752
- # Delegates to StreamWriter#table.
1753
- # @see StreamWriter#table
1938
+ # Add a formatted Excel Table to the sheet.
1939
+ #
1940
+ # @example
1941
+ # s.table("A1:C10", columns: ["ID", "Name", "Total"], name: "SalesTable", style: "TableStyleMedium9")
1942
+ #
1943
+ # @param ref [String] The cell range for the table (e.g. "A1:D10").
1944
+ # @param columns [Array<String>, Array<Hash>] Column names or definitions.
1945
+ # @param name [String, nil] Table name.
1946
+ # @param display_name [String, nil] Display name.
1947
+ # @param style [String, nil] Table style name.
1948
+ # @param opts [Hash] Additional options.
1949
+ # @return [void]
1754
1950
  # @api public
1755
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1951
+ #: (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void
1756
1952
  def table(...)
1757
1953
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1758
1954
 
1759
1955
  @writer.table(...)
1760
1956
  end
1761
1957
 
1762
- # Delegates to StreamWriter#cleanup!.
1763
- # @see StreamWriter#cleanup!
1764
- # @api public
1765
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1958
+ # simplecov:disable
1959
+ # Edge case / untested delegation block
1960
+ #: () -> void
1766
1961
  def cleanup!(...)
1767
1962
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1768
1963
 
1769
- # simplecov:disable
1770
- # Edge case / untested delegation block
1771
1964
  @writer.cleanup!(...)
1772
- # simplecov:enable
1773
1965
  end
1966
+ # simplecov:enable
1774
1967
 
1775
- # Delegates to StreamWriter#comment.
1776
- # @see StreamWriter#comment
1968
+ # Add a comment to a cell.
1969
+ #
1970
+ # @example
1971
+ # s.comment("A1", "Reviewed and approved", author: "Auditor")
1972
+ #
1973
+ # @param cell [String, Integer] The cell reference (e.g. "A1").
1974
+ # @param text [String] The comment text.
1975
+ # @param author [String] The author name.
1976
+ # @return [void]
1777
1977
  # @api public
1778
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
1978
+ #: (String | Integer cell, String text, ?author: String) -> void
1779
1979
  def comment(...)
1780
1980
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1781
1981
 
1782
1982
  @writer.comment(...)
1783
1983
  end
1784
1984
 
1785
- # Delegates to StreamWriter#pivot_table.
1786
- # @see StreamWriter#pivot_table
1985
+ # Add a Pivot Table to the sheet.
1986
+ #
1987
+ # @example
1988
+ # s.pivot_table("Sheet1!A1:D100", row_fields: ["Category"], data_fields: ["Amount"], dest_ref: "F1")
1989
+ #
1990
+ # @param source_ref [String] Source data range reference (e.g. "Sheet1!A1:D100").
1991
+ # @param row_fields [Array<String>] Field names for rows.
1992
+ # @param data_fields [Array<String>] Field names for data values.
1993
+ # @param col_fields [Array<String>] Field names for columns.
1994
+ # @param dest_ref [String] Target top-left cell reference (default: "E1").
1995
+ # @param name [String, nil] Pivot table name.
1996
+ # @param field_names [Array<String>, nil] Override field names.
1997
+ # @param items [Array, nil] Items configuration.
1998
+ # @param opts [Hash] Additional options.
1999
+ # @return [void]
1787
2000
  # @api public
1788
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2001
+ #: (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
1789
2002
  def pivot_table(...)
1790
2003
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1791
2004
 
1792
2005
  @writer.pivot_table(...)
1793
2006
  end
1794
2007
 
1795
- # Delegates to StreamWriter#sparkline_group.
1796
- # @see StreamWriter#sparkline_group
2008
+ # Add sparklines to the sheet.
2009
+ #
2010
+ # @example
2011
+ # s.sparkline_group(sparklines: [{ data_ref: "A1:E1", location_ref: "F1" }], type: "line")
2012
+ #
2013
+ # @param sparklines [Array<Hash>] Array of { data_ref:, location_ref: } hashes.
2014
+ # @param type [String, nil] "line" (default), "column", or "stacked".
2015
+ # @param opts [Hash] Additional sparkline options.
2016
+ # @return [void]
1797
2017
  # @api public
1798
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2018
+ #: (sparklines: Array[Hash[Symbol, untyped]], ?type: String?, **untyped opts) -> void
1799
2019
  def sparkline_group(...)
1800
2020
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1801
2021
 
1802
2022
  @writer.sparkline_group(...)
1803
2023
  end
1804
2024
 
1805
- # Delegates to StreamWriter#workbook_property.
1806
- # @see StreamWriter#workbook_property
2025
+ # Set workbook-level properties.
2026
+ #
2027
+ # @param opts [Hash] Workbook property options.
2028
+ # @return [void]
1807
2029
  # @api public
1808
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2030
+ #: (**untyped opts) -> void
1809
2031
  def workbook_property(...)
1810
2032
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1811
2033
 
1812
2034
  @writer.workbook_property(...)
1813
2035
  end
1814
2036
 
1815
- # Delegates to StreamWriter#sheet_properties.
1816
- # @see StreamWriter#sheet_properties
2037
+ # Set sheet properties (e.g. tab color, page setup flags).
2038
+ #
2039
+ # @example
2040
+ # s.sheet_properties(:tab_color, "FF0000")
2041
+ #
2042
+ # @param name [Symbol, String] Property name.
2043
+ # @param value [Object] Property value.
2044
+ # @return [void]
1817
2045
  # @api public
1818
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2046
+ #: (Symbol | String name, untyped value) -> void
1819
2047
  def sheet_properties(...)
1820
2048
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1821
2049
 
1822
2050
  @writer.sheet_properties(...)
1823
2051
  end
1824
2052
 
1825
- # Delegates to StreamWriter#defined_name.
1826
- # @see StreamWriter#defined_name
2053
+ # Add a defined named range or formula.
2054
+ #
2055
+ # @example
2056
+ # s.defined_name("TaxRate", "0.10")
2057
+ #
2058
+ # @param name [String] The name.
2059
+ # @param formula [String] The formula or range expression.
2060
+ # @param sheet_id [Integer, nil] Optional sheet scope.
2061
+ # @param hidden [Boolean] Whether the name is hidden.
2062
+ # @return [void]
1827
2063
  # @api public
1828
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2064
+ #: (String name, String formula, ?sheet_id: Integer | nil, ?hidden: bool) -> void
1829
2065
  def defined_name(...)
1830
2066
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1831
2067
 
1832
2068
  @writer.defined_name(...)
1833
2069
  end
1834
2070
 
1835
- # Delegates to StreamWriter#freeze_pane.
1836
- # @see StreamWriter#freeze_pane
2071
+ # Freeze rows and/or columns for scrolling.
2072
+ #
2073
+ # @example Freeze top row
2074
+ # s.freeze_pane(row: 1)
2075
+ #
2076
+ # @example Freeze first column and top 2 rows
2077
+ # s.freeze_pane(row: 2, col: 1)
2078
+ #
2079
+ # @param row [Integer, nil] Number of rows to freeze.
2080
+ # @param col [Integer, nil] Number of columns to freeze.
2081
+ # @return [void]
1837
2082
  # @api public
1838
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2083
+ #: (?row: Integer | nil, ?col: Integer | nil) -> void
1839
2084
  def freeze_pane(...)
1840
2085
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1841
2086
 
1842
2087
  @writer.freeze_pane(...)
1843
2088
  end
1844
2089
 
1845
- # Delegates to StreamWriter#print_area.
1846
- # @see StreamWriter#print_area
2090
+ # simplecov:disable
2091
+ # Edge case / untested delegation block
2092
+ # Set the print area range for the sheet.
2093
+ #
2094
+ # @example
2095
+ # s.print_area("A1:G50")
2096
+ #
2097
+ # @param ref [String] Range reference.
2098
+ # @return [void]
1847
2099
  # @api public
1848
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2100
+ #: (String ref) -> void
1849
2101
  def print_area(...)
1850
- # simplecov:disable
1851
- # Edge case / untested delegation block
1852
2102
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1853
2103
 
1854
2104
  @writer.print_area(...)
1855
- # simplecov:enable
1856
2105
  end
2106
+ # simplecov:enable
1857
2107
 
1858
- # Delegates to StreamWriter#print_titles.
1859
- # @see StreamWriter#print_titles
2108
+ # simplecov:disable
2109
+ # Edge case / untested delegation block
2110
+ # Configure repeating title rows and columns for printing.
2111
+ #
2112
+ # @example Repeat top 2 rows on every page
2113
+ # s.print_titles(rows: "1:2")
2114
+ #
2115
+ # @param rows [String, nil] Row range to repeat (e.g. "1:2").
2116
+ # @param cols [String, nil] Column range to repeat (e.g. "A:B").
2117
+ # @return [void]
1860
2118
  # @api public
1861
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2119
+ #: (?rows: String?, ?cols: String?) -> void
1862
2120
  def print_titles(...)
1863
- # simplecov:disable
1864
- # Edge case / untested delegation block
1865
2121
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1866
2122
 
1867
2123
  @writer.print_titles(...)
1868
- # simplecov:enable
1869
2124
  end
2125
+ # simplecov:enable
1870
2126
 
1871
- # Delegates to StreamWriter#split_pane.
1872
- # @see StreamWriter#split_pane
2127
+ # Split sheet view into panes.
2128
+ #
2129
+ # @param x_split [Numeric, nil] Horizontal split position.
2130
+ # @param y_split [Numeric, nil] Vertical split position.
2131
+ # @param top_left_cell [String, nil] Top-left visible cell in bottom-right pane.
2132
+ # @param active_pane [String, nil] Active pane identifier.
2133
+ # @param state [String, nil] Split state.
2134
+ # @return [void]
1873
2135
  # @api public
1874
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2136
+ #: (?x_split: Numeric | nil, ?y_split: Numeric | nil, ?top_left_cell: String?, ?active_pane: String?, ?state: String?) -> void
1875
2137
  def split_pane(...)
1876
2138
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1877
2139
 
1878
2140
  @writer.split_pane(...)
1879
2141
  end
1880
2142
 
1881
- # Delegates to StreamWriter#protect_workbook.
1882
- # @see StreamWriter#protect_workbook
2143
+ # simplecov:disable
2144
+ # Edge case / untested delegation block
2145
+ # Protect the workbook structure.
2146
+ #
2147
+ # @param opts [Hash] Protection options.
2148
+ # @return [void]
1883
2149
  # @api public
1884
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2150
+ #: (**untyped opts) -> void
1885
2151
  def protect_workbook(...)
1886
- # simplecov:disable
1887
- # Edge case / untested delegation block
1888
2152
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1889
2153
 
1890
2154
  @writer.protect_workbook(...)
1891
- # simplecov:enable
1892
2155
  end
2156
+ # simplecov:enable
1893
2157
 
1894
- # Delegates to StreamWriter#core_property.
1895
- # @see StreamWriter#core_property
2158
+ # simplecov:disable
2159
+ # Edge case / untested delegation block
2160
+ # Set core metadata property.
2161
+ #
2162
+ # @param name [String, Symbol] Property name.
2163
+ # @param value [Object] Property value.
2164
+ # @return [void]
1896
2165
  # @api public
1897
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2166
+ #: (String | Symbol name, untyped value) -> void
1898
2167
  def core_property(...)
1899
- # simplecov:disable
1900
- # Edge case / untested delegation block
1901
2168
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1902
2169
 
1903
2170
  @writer.core_property(...)
1904
- # simplecov:enable
1905
2171
  end
2172
+ # simplecov:enable
1906
2173
 
1907
- # Delegates to StreamWriter#select_cell.
1908
- # @see StreamWriter#select_cell
2174
+ # Set the active/selected cell on the sheet.
2175
+ #
2176
+ # @example
2177
+ # s.select_cell("B5")
2178
+ # s.select_cell("A1", sqref: "A1:A2", pane: "topRight")
2179
+ #
2180
+ # @param active_cell [String] Cell reference (e.g. "A1").
2181
+ # @param sqref [String, nil] Selection range.
2182
+ # @param pane [String, Symbol, nil] Pane identifier.
2183
+ # @return [void]
1909
2184
  # @api public
1910
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2185
+ #: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
1911
2186
  def select_cell(...)
1912
2187
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1913
2188
 
1914
2189
  @writer.select_cell(...)
1915
2190
  end
1916
2191
 
1917
- # Delegates to StreamWriter#page_margins.
1918
- # @see StreamWriter#page_margins
2192
+ # Configure page margins for printing.
2193
+ #
2194
+ # @example
2195
+ # s.page_margins(left: 0.7, right: 0.7, top: 0.75, bottom: 0.75)
2196
+ #
2197
+ # @param left [Float, nil] Left margin in inches.
2198
+ # @param right [Float, nil] Right margin in inches.
2199
+ # @param top [Float, nil] Top margin in inches.
2200
+ # @param bottom [Float, nil] Bottom margin in inches.
2201
+ # @param header [Float, nil] Header margin in inches.
2202
+ # @param footer [Float, nil] Footer margin in inches.
2203
+ # @return [void]
1919
2204
  # @api public
1920
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2205
+ #: (?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) -> void
1921
2206
  def page_margins(...)
1922
2207
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1923
2208
 
1924
2209
  @writer.page_margins(...)
1925
2210
  end
1926
2211
 
1927
- # Delegates to StreamWriter#page_setup.
1928
- # @see StreamWriter#page_setup
2212
+ # Configure page orientation, paper size, and print setup.
2213
+ #
2214
+ # @example Landscape A4
2215
+ # s.page_setup(orientation: "landscape", paper_size: 9)
2216
+ #
2217
+ # @param orientation [String, Symbol, nil] "portrait" or "landscape" (or :portrait, :landscape).
2218
+ # @param paper_size [Integer, nil] Paper size index (e.g. 9 for A4, 1 for Letter).
2219
+ # @param opts [Hash] Additional options (scale, fit_to_width, fit_to_height).
2220
+ # @return [void]
1929
2221
  # @api public
1930
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2222
+ #: (?orientation: (String | Symbol)?, ?paper_size: Integer | nil, **untyped opts) -> void
1931
2223
  def page_setup(...)
1932
2224
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1933
2225
 
1934
2226
  @writer.page_setup(...)
1935
2227
  end
1936
2228
 
1937
- # Delegates to StreamWriter#header_footer.
1938
- # @see StreamWriter#header_footer
2229
+ # Configure header and footer text for printing.
2230
+ #
2231
+ # @example
2232
+ # s.header_footer(odd_header: "&CConfidential", odd_footer: "&RPage &P of &N")
2233
+ #
2234
+ # @param opts [Hash] Header and footer specifications.
2235
+ # @return [void]
1939
2236
  # @api public
1940
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2237
+ #: (**untyped opts) -> void
1941
2238
  def header_footer(...)
1942
2239
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1943
2240
 
1944
2241
  @writer.header_footer(...)
1945
2242
  end
1946
2243
 
1947
- # Delegates to StreamWriter#print_options.
1948
- # @see StreamWriter#print_options
2244
+ # Configure print options (e.g. gridlines, headings).
2245
+ #
2246
+ # @example
2247
+ # s.print_options(:grid_lines, true)
2248
+ #
2249
+ # @param name [Symbol, String] Print option name.
2250
+ # @param value [Object] Print option value.
2251
+ # @return [void]
1949
2252
  # @api public
1950
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2253
+ #: (Symbol | String name, untyped value) -> void
1951
2254
  def print_options(...)
1952
2255
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1953
2256
 
1954
2257
  @writer.print_options(...)
1955
2258
  end
1956
2259
 
1957
- # Delegates to StreamWriter#properties.
1958
- # @see StreamWriter#properties
2260
+ # simplecov:disable
2261
+ # Edge case / untested delegation block
2262
+ # Set document metadata properties (core, app, custom).
2263
+ #
2264
+ # @example
2265
+ # s.properties(core: { title: "Report", creator: "App" })
2266
+ #
2267
+ # @param core [Hash, nil] Core properties (title, creator, subject, etc.).
2268
+ # @param app [Hash, nil] App properties (company, manager).
2269
+ # @param custom [Hash, nil] Custom properties.
2270
+ # @return [void]
1959
2271
  # @api public
1960
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2272
+ #: (?core: Hash[untyped, untyped]?, ?app: Hash[untyped, untyped]?, ?custom: Hash[untyped, untyped]?) -> void
1961
2273
  def properties(...)
1962
- # simplecov:disable
1963
- # Edge case / untested delegation block
1964
2274
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1965
2275
 
1966
2276
  @writer.properties(...)
1967
- # simplecov:enable
1968
2277
  end
2278
+ # simplecov:enable
1969
2279
 
1970
- # Delegates to StreamWriter#app_property.
1971
- # @see StreamWriter#app_property
2280
+ # simplecov:disable
2281
+ # Edge case / untested delegation block
2282
+ # Set app metadata property.
2283
+ #
2284
+ # @param name [String, Symbol] Property name.
2285
+ # @param value [Object] Property value.
2286
+ # @return [void]
1972
2287
  # @api public
1973
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2288
+ #: (String | Symbol name, untyped value) -> void
1974
2289
  def app_property(...)
1975
- # simplecov:disable
1976
- # Edge case / untested delegation block
1977
2290
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1978
2291
 
1979
2292
  @writer.app_property(...)
1980
- # simplecov:enable
1981
2293
  end
2294
+ # simplecov:enable
1982
2295
 
1983
- # Delegates to StreamWriter#protect_sheet.
1984
- # @see StreamWriter#protect_sheet
2296
+ # Protect the worksheet against modifications.
2297
+ #
2298
+ # @example
2299
+ # s.protect_sheet(password: "secret", select_locked_cells: true)
2300
+ #
2301
+ # @param opts [Hash] Protection options.
2302
+ # @return [void]
1985
2303
  # @api public
1986
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2304
+ #: (**untyped opts) -> void
1987
2305
  def protect_sheet(...)
1988
2306
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
1989
2307
 
1990
2308
  @writer.protect_sheet(...)
1991
2309
  end
1992
2310
 
1993
- # Delegates to StreamWriter#custom_property.
1994
- # @see StreamWriter#custom_property
2311
+ # simplecov:disable
2312
+ # Edge case / untested delegation block
2313
+ # Set custom metadata property.
2314
+ #
2315
+ # @param name [String, Symbol] Property name.
2316
+ # @param value [Object] Property value.
2317
+ # @return [void]
1995
2318
  # @api public
1996
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2319
+ #: (String | Symbol name, untyped value) -> void
1997
2320
  def custom_property(...)
1998
- # simplecov:disable
1999
- # Edge case / untested delegation block
2000
2321
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
2001
2322
 
2002
2323
  @writer.custom_property(...)
2003
- # simplecov:enable
2004
2324
  end
2325
+ # simplecov:enable
2005
2326
 
2006
- # Delegates to StreamWriter#image.
2007
- # @see StreamWriter#image
2327
+ # Insert an image into the sheet.
2328
+ #
2329
+ # @example
2330
+ # s.image(File.read("logo.png"), ext: "png", from_col: 0, from_row: 0, to_col: 2, to_row: 3)
2331
+ #
2332
+ # @param file_data [String] Binary image data or file content.
2333
+ # @param ext [String] Image extension ("png", "jpeg", etc.).
2334
+ # @param from_col [Integer] Starting column index (0-based).
2335
+ # @param from_row [Integer] Starting row index (0-based).
2336
+ # @param to_col [Integer] Ending column index (0-based).
2337
+ # @param to_row [Integer] Ending row index (0-based).
2338
+ # @param opts [Hash] Additional anchor and sizing options.
2339
+ # @return [void]
2008
2340
  # @api public
2009
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2341
+ #: (String file_data, ?ext: String, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
2010
2342
  def image(...)
2011
2343
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
2012
2344
 
2013
2345
  @writer.image(...)
2014
2346
  end
2015
2347
 
2016
- # Delegates to StreamWriter#sheet_view.
2017
- # @see StreamWriter#sheet_view
2348
+ # Configure sheet view settings (zoom scale, grid lines visibility).
2349
+ #
2350
+ # @example
2351
+ # s.sheet_view(:show_grid_lines, false)
2352
+ # s.sheet_view(:zoom_scale, 120)
2353
+ #
2354
+ # @param name [Symbol, String] View setting name.
2355
+ # @param value [Object] View setting value.
2356
+ # @return [void]
2018
2357
  # @api public
2019
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2358
+ #: (Symbol | String name, untyped value) -> void
2020
2359
  def sheet_view(...)
2021
2360
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
2022
2361
 
2023
2362
  @writer.sheet_view(...)
2024
2363
  end
2025
2364
 
2026
- # Delegates to StreamWriter#page_break_row.
2027
- # @see StreamWriter#page_break_row
2365
+ # simplecov:disable
2366
+ # Edge case / untested delegation block
2367
+ # Add a horizontal page break after the given row index.
2368
+ #
2369
+ # @example
2370
+ # s.page_break_row(25)
2371
+ #
2372
+ # @param row_index [Integer] 0-based row index.
2373
+ # @return [void]
2028
2374
  # @api public
2029
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2375
+ #: (Integer row_index) -> void
2030
2376
  def page_break_row(...)
2031
- # simplecov:disable
2032
- # Edge case / untested delegation block
2033
2377
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
2034
2378
 
2035
2379
  @writer.page_break_row(...)
2036
- # simplecov:enable
2037
2380
  end
2381
+ # simplecov:enable
2038
2382
 
2039
- # Delegates to StreamWriter#page_break_col.
2040
- # @see StreamWriter#page_break_col
2383
+ # simplecov:disable
2384
+ # Edge case / untested delegation block
2385
+ # Add a vertical page break after the given column index.
2386
+ #
2387
+ # @example
2388
+ # s.page_break_col(5)
2389
+ #
2390
+ # @param col_index [Integer] 0-based column index.
2391
+ # @return [void]
2041
2392
  # @api public
2042
- #: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
2393
+ #: (Integer col_index) -> void
2043
2394
  def page_break_col(...)
2044
- # simplecov:disable
2045
- # Edge case / untested delegation block
2046
2395
  raise Error, "Sheet '' is no longer active. In streaming mode, you cannot write to a previous sheet." if @writer.current_sheet != @sheet_name
2047
2396
 
2048
2397
  @writer.page_break_col(...)
2049
- # simplecov:enable
2050
2398
  end
2399
+ # simplecov:enable
2051
2400
  end
2052
2401
 
2053
2402
  # Add a new sheet.
@@ -2315,7 +2664,7 @@ module Xlsxrb
2315
2664
  end
2316
2665
 
2317
2666
  # --- Tables ---
2318
- #: (untyped ref, **untyped opts) -> void
2667
+ #: (untyped ref, columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) -> void
2319
2668
  def table(ref, columns:, name: nil, display_name: nil, style: nil, **opts)
2320
2669
  sheet if @current_sheet.nil?
2321
2670
  tbl = { ref: ref, columns: columns }
@@ -2327,7 +2676,7 @@ module Xlsxrb
2327
2676
  end
2328
2677
 
2329
2678
  # --- Pivot Tables ---
2330
- #: (untyped source_ref, **untyped opts) -> void
2679
+ #: (untyped source_ref, row_fields: untyped, data_fields: untyped, ?col_fields: untyped, ?dest_ref: untyped, ?name: untyped, ?field_names: untyped, ?items: untyped, **untyped opts) -> void
2331
2680
  def pivot_table(source_ref, row_fields:, data_fields:, col_fields: [], dest_ref: "E1", name: nil, field_names: nil, items: nil)
2332
2681
  sheet if @current_sheet.nil?
2333
2682
  @current_pivot_tables ||= []
@@ -2347,7 +2696,7 @@ module Xlsxrb
2347
2696
  end
2348
2697
 
2349
2698
  # --- Sparklines ---
2350
- #: (**untyped opts) -> void
2699
+ #: (sparklines: untyped, ?type: untyped, **untyped opts) -> void
2351
2700
  def sparkline_group(sparklines:, type: nil, **opts)
2352
2701
  sheet if @current_sheet.nil?
2353
2702
  group = { sparklines: sparklines }