xlsxrb 0.1.6 → 0.1.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +110 -43
- data/Rakefile +16 -5
- data/Steepfile +1 -0
- data/benchmark.rb +32 -4
- data/docs/ARCHITECTURE.md +32 -30
- data/docs/visual/VisualGallery.md +165 -157
- data/docs/wasm/ruby.wasm +0 -0
- data/lib/ruby_lsp/xlsxrb/addon.rb +43 -0
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +767 -0
- data/lib/xlsxrb/elements/cell.rb +98 -4
- data/lib/xlsxrb/elements/column.rb +22 -0
- data/lib/xlsxrb/elements/coordinate_access.rb +101 -0
- data/lib/xlsxrb/elements/row.rb +81 -1
- data/lib/xlsxrb/elements/types.rb +36 -5
- data/lib/xlsxrb/elements/workbook.rb +92 -6
- data/lib/xlsxrb/elements/worksheet.rb +138 -59
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +21 -15
- data/lib/xlsxrb/stream_row.rb +181 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb.rb +654 -247
- data/sig/generated/xlsxrb/elements/cell.rbs +10 -1
- data/sig/generated/xlsxrb/elements/column.rbs +5 -0
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +70 -0
- data/sig/generated/xlsxrb/elements/row.rbs +8 -1
- data/sig/generated/xlsxrb/elements/types.rbs +13 -5
- data/sig/generated/xlsxrb/elements/workbook.rbs +8 -1
- data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -12
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +2 -0
- data/sig/generated/xlsxrb/stream_row.rbs +125 -0
- data/sig/generated/xlsxrb.rbs +674 -262
- metadata +7 -1
data/sig/generated/xlsxrb.rbs
CHANGED
|
@@ -253,39 +253,101 @@ module Xlsxrb
|
|
|
253
253
|
|
|
254
254
|
# Creates a Formula object for use in row values.
|
|
255
255
|
#
|
|
256
|
-
# @
|
|
256
|
+
# @example Create a basic sum formula
|
|
257
|
+
# formula = Xlsxrb.formula("SUM(A1:A10)")
|
|
258
|
+
#
|
|
259
|
+
# @example Create a formula with precomputed cached value
|
|
260
|
+
# formula = Xlsxrb.formula("A1+B1", cached_value: 42)
|
|
261
|
+
#
|
|
262
|
+
# @param expression [String] The formula text without '=' (e.g. "SUM(A1:A10)").
|
|
257
263
|
# @param cached_value [Object, nil] Optional cached result. If nil, Excel will calculate on open.
|
|
258
264
|
# @return [Elements::Formula]
|
|
259
265
|
# @api public
|
|
260
|
-
# : (String expression, ?cached_value: String | Numeric | bool | nil) ->
|
|
261
|
-
def self.formula: (String expression, ?cached_value: String | Numeric | bool | nil) ->
|
|
266
|
+
# : (String expression, ?cached_value: String | Numeric | bool | nil) -> Elements::Formula
|
|
267
|
+
def self.formula: (String expression, ?cached_value: String | Numeric | bool | nil) -> Elements::Formula
|
|
262
268
|
|
|
263
|
-
# Reads an XLSX file
|
|
269
|
+
# Reads an XLSX file (streaming / lazy-loaded by default) from a file path, IO stream, or binary String.
|
|
270
|
+
#
|
|
271
|
+
# Sheets and rows are streamed lazily with O(1) constant memory. If a block is given,
|
|
272
|
+
# yields each StreamSheet sequentially.
|
|
273
|
+
#
|
|
274
|
+
# Call #load on the returned Workbook or Sheet to convert to an in-memory representation
|
|
275
|
+
# for coordinate random access (e.g. sheet["A1"]).
|
|
276
|
+
#
|
|
277
|
+
# @example Streaming read across sheets and rows (O(1) memory)
|
|
278
|
+
# Xlsxrb.read("large.xlsx") do |sheet|
|
|
279
|
+
# puts "Sheet: #{sheet.name}"
|
|
280
|
+
# sheet.each_row do |row|
|
|
281
|
+
# row.each_cell { |cell| puts "#{cell.ref}: #{cell.value}" }
|
|
282
|
+
# end
|
|
283
|
+
# end
|
|
284
|
+
#
|
|
285
|
+
# @example Lazy workbook access and explicit in-memory loading
|
|
286
|
+
# wb = Xlsxrb.read("data.xlsx")
|
|
287
|
+
# sheet = wb.sheets.first
|
|
288
|
+
# sheet.each_row { |row| ... } # streams with O(1) memory
|
|
289
|
+
# doc_sheet = sheet.load # explicitly load into memory
|
|
290
|
+
# puts doc_sheet["A1"].value # coordinate random access
|
|
264
291
|
#
|
|
265
|
-
# @param source [String, IO] File path or IO object.
|
|
266
|
-
# @
|
|
292
|
+
# @param source [String, IO] File path, binary content string (starting with PK..), or IO object.
|
|
293
|
+
# @yield [sheet] Yields each streaming sheet.
|
|
294
|
+
# @yieldparam sheet [StreamSheet] The streaming worksheet object.
|
|
295
|
+
# @return [Elements::Workbook, void] Returns Elements::Workbook when no block is given.
|
|
267
296
|
# @api public
|
|
268
|
-
# : (
|
|
269
|
-
|
|
297
|
+
# : (String | IO source) { (StreamSheet) -> void } -> void
|
|
298
|
+
# : (String | IO source) -> Elements::Workbook
|
|
299
|
+
def self.read: (String | IO source) { (StreamSheet) -> void } -> void
|
|
300
|
+
| (String | IO source) -> Elements::Workbook
|
|
270
301
|
|
|
271
|
-
# Writes an
|
|
302
|
+
# Writes an XLSX file or IO stream (streaming or in-memory), or returns a binary string.
|
|
303
|
+
#
|
|
304
|
+
# @overload write(target, strict_excel_mode: true, &block)
|
|
305
|
+
# Streaming write: yields a StreamWriter context for high-speed, zero-allocation XLSX generation.
|
|
306
|
+
# @param target [String, IO] Destination file path or writable IO object.
|
|
307
|
+
# @param strict_excel_mode [Boolean] Whether to enforce Excel specifications.
|
|
308
|
+
# @yield [stream_writer]
|
|
309
|
+
# @yieldparam stream_writer [Xlsxrb::StreamWriter]
|
|
310
|
+
# @return [void]
|
|
311
|
+
#
|
|
312
|
+
# @overload write(workbook)
|
|
313
|
+
# In-memory write: exports the workbook to an in-memory binary String.
|
|
314
|
+
# @param workbook [Elements::Workbook] The workbook to write.
|
|
315
|
+
# @return [String] Binary data representing the XLSX file.
|
|
316
|
+
#
|
|
317
|
+
# @overload write(target, workbook)
|
|
318
|
+
# In-memory write: writes the workbook to a file path or IO stream.
|
|
319
|
+
# @param target [String, IO] Destination file path or writable IO object.
|
|
320
|
+
# @param workbook [Elements::Workbook] The workbook to write.
|
|
321
|
+
# @return [void]
|
|
322
|
+
#
|
|
323
|
+
# @example Streaming write to file
|
|
324
|
+
# Xlsxrb.write("output.xlsx") do |writer|
|
|
325
|
+
# writer.sheet("Sheet1") { |s| s.row(["Hello", "World"]) }
|
|
326
|
+
# end
|
|
327
|
+
#
|
|
328
|
+
# @example In-memory export to binary string
|
|
329
|
+
# binary_data = Xlsxrb.write(workbook)
|
|
330
|
+
#
|
|
331
|
+
# @example In-memory write to file
|
|
332
|
+
# Xlsxrb.write("output.xlsx", workbook)
|
|
272
333
|
#
|
|
273
|
-
# @param target [String, IO] File path or IO object.
|
|
274
|
-
# @param workbook [Elements::Workbook] The workbook to write.
|
|
275
|
-
# @return [void]
|
|
276
334
|
# @api public
|
|
277
|
-
# : (
|
|
278
|
-
|
|
335
|
+
# : (Elements::Workbook workbook) -> String
|
|
336
|
+
# : (String | IO target, Elements::Workbook workbook) -> void
|
|
337
|
+
# : (String | IO target, ?strict_excel_mode: bool) ?{ (StreamWriter) -> void } -> void
|
|
338
|
+
def self.write: (Elements::Workbook workbook) -> String
|
|
339
|
+
| (String | IO target, Elements::Workbook workbook) -> void
|
|
340
|
+
| (String | IO target, ?strict_excel_mode: bool) ?{ (StreamWriter) -> void } -> void
|
|
279
341
|
|
|
280
342
|
# Modifies an existing XLSX file.
|
|
281
343
|
# Reads the workbook, passes it to the block, and writes the result.
|
|
282
344
|
# The block receives an Elements::Workbook and must return a modified one (e.g. via `update_sheet`).
|
|
283
345
|
# If no target is given, the source is overwritten.
|
|
284
346
|
#
|
|
285
|
-
# @example
|
|
286
|
-
# Xlsxrb.modify("template.xlsx", "output.xlsx") do |
|
|
287
|
-
#
|
|
288
|
-
# sheet.update_cell("B1", value: "Updated")
|
|
347
|
+
# @example Modify a template and save to new file
|
|
348
|
+
# Xlsxrb.modify("template.xlsx", "output.xlsx") do |workbook|
|
|
349
|
+
# workbook.update_sheet("Sheet1") do |sheet|
|
|
350
|
+
# sheet.update_cell("B1", value: "Updated Title")
|
|
289
351
|
# .update_cell("B2", value: 100)
|
|
290
352
|
# end
|
|
291
353
|
# end
|
|
@@ -297,53 +359,100 @@ module Xlsxrb
|
|
|
297
359
|
# @yieldreturn [Elements::Workbook] The modified workbook.
|
|
298
360
|
# @return [void]
|
|
299
361
|
# @api public
|
|
300
|
-
# : (untyped source, ?untyped target) ?{ (
|
|
301
|
-
def self.modify: (untyped source, ?untyped target) ?{ (
|
|
362
|
+
# : (untyped source, ?untyped target) ?{ (Elements::Workbook) -> untyped } -> void
|
|
363
|
+
def self.modify: (untyped source, ?untyped target) ?{ (Elements::Workbook) -> untyped } -> void
|
|
302
364
|
|
|
303
|
-
# Represents a sheet being streamed sequentially.
|
|
365
|
+
# Represents a sheet being streamed sequentially from an XLSX file.
|
|
366
|
+
# Provides O(1) constant-memory streaming over rows and cells.
|
|
367
|
+
#
|
|
368
|
+
# Call #load (or #to_worksheet) to convert this streaming sheet into an
|
|
369
|
+
# in-memory Elements::Worksheet supporting coordinate random access (sheet["A1"]).
|
|
370
|
+
#
|
|
371
|
+
# @example Iterate rows and cells in streaming mode (O(1) memory)
|
|
372
|
+
# Xlsxrb.read("large_data.xlsx") do |sheet|
|
|
373
|
+
# puts "Processing sheet: #{sheet.name}"
|
|
374
|
+
# sheet.each_row do |row|
|
|
375
|
+
# row.each_cell do |cell|
|
|
376
|
+
# puts "#{cell.ref}: #{cell.value}"
|
|
377
|
+
# end
|
|
378
|
+
# end
|
|
379
|
+
# end
|
|
380
|
+
#
|
|
381
|
+
# @example Load into an in-memory Worksheet for coordinate random access
|
|
382
|
+
# wb = Xlsxrb.read("data.xlsx")
|
|
383
|
+
# doc_sheet = wb.sheet(0).load
|
|
384
|
+
# puts doc_sheet["A1"].value
|
|
385
|
+
#
|
|
386
|
+
# @api public
|
|
304
387
|
class StreamSheet
|
|
305
388
|
attr_reader name: untyped
|
|
306
389
|
|
|
307
|
-
|
|
390
|
+
# @param name [String] The sheet name.
|
|
391
|
+
# @param sheet_xml [String] Raw XML content of the sheet.
|
|
392
|
+
# @param shared_strings [Array<String>] Shared strings table.
|
|
393
|
+
# @param styles [Hash, nil] Styles table.
|
|
394
|
+
# : (String name, String sheet_xml, Array[String] shared_strings, ?Hash[untyped, untyped]? styles) -> void
|
|
395
|
+
def initialize: (String name, String sheet_xml, Array[String] shared_strings, ?Hash[untyped, untyped]? styles) -> void
|
|
308
396
|
|
|
309
|
-
#
|
|
310
|
-
#
|
|
311
|
-
|
|
397
|
+
# Iterate over rows in this streaming sheet (O(1) memory).
|
|
398
|
+
#
|
|
399
|
+
# @yield [row]
|
|
400
|
+
# @yieldparam row [StreamRow, Elements::Row]
|
|
401
|
+
# @return [Enumerator, void]
|
|
402
|
+
# @api public
|
|
403
|
+
# : () { (StreamRow | Elements::Row) -> void } -> void
|
|
404
|
+
# : | () -> Enumerator[StreamRow | Elements::Row, void]
|
|
405
|
+
def each_row: () { (StreamRow | Elements::Row) -> void } -> void
|
|
312
406
|
|
|
313
|
-
#
|
|
314
|
-
#
|
|
315
|
-
|
|
316
|
-
|
|
407
|
+
# Iterate over all cells across rows continuously (O(1) memory).
|
|
408
|
+
#
|
|
409
|
+
# @yield [cell]
|
|
410
|
+
# @yieldparam cell [Elements::Cell]
|
|
411
|
+
# @return [Enumerator, void]
|
|
412
|
+
# @api public
|
|
413
|
+
# : () { (Elements::Cell) -> void } -> void
|
|
414
|
+
# : | () -> Enumerator[Elements::Cell, void]
|
|
415
|
+
def each_cell: () { (Elements::Cell) -> void } -> void
|
|
317
416
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
def self.foreach: (untyped source) ?{ (StreamSheet) -> void } -> untyped
|
|
417
|
+
# Default Enumerable iteration iterates rows in the streaming sheet.
|
|
418
|
+
#
|
|
419
|
+
# @yield [row]
|
|
420
|
+
# @yieldparam row [StreamRow, Elements::Row]
|
|
421
|
+
# @return [Enumerator, void]
|
|
422
|
+
# @api public
|
|
423
|
+
# : () { (StreamRow | Elements::Row) -> void } -> void
|
|
424
|
+
# : | () -> Enumerator[StreamRow | Elements::Row, void]
|
|
425
|
+
def each: () { (StreamRow | Elements::Row) -> void } -> void
|
|
328
426
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
427
|
+
# Loads this sheet completely into an in-memory Elements::Worksheet,
|
|
428
|
+
# enabling coordinate random access (sheet["A1"]), row lookups (row_at),
|
|
429
|
+
# and immutable cell updates (update_cell).
|
|
430
|
+
#
|
|
431
|
+
# @return [Elements::Worksheet] The fully parsed in-memory worksheet.
|
|
432
|
+
# @api public
|
|
433
|
+
# : () -> Elements::Worksheet
|
|
434
|
+
def load: () -> Elements::Worksheet
|
|
435
|
+
|
|
436
|
+
alias to_worksheet load
|
|
437
|
+
end
|
|
338
438
|
|
|
339
|
-
# Builds an Elements::Workbook
|
|
439
|
+
# Builds an in-memory Elements::Workbook using a declarative DSL.
|
|
340
440
|
#
|
|
441
|
+
# @example Build in-memory workbook
|
|
442
|
+
# workbook = Xlsxrb.build do |builder|
|
|
443
|
+
# builder.sheet("Overview") do |sheet|
|
|
444
|
+
# sheet.row(["Title", "Date"])
|
|
445
|
+
# sheet.row(["Report", Date.today])
|
|
446
|
+
# end
|
|
447
|
+
# end
|
|
448
|
+
#
|
|
449
|
+
# @param strict_excel_mode [Boolean] Whether to enforce Excel specifications.
|
|
341
450
|
# @yield [builder]
|
|
342
451
|
# @yieldparam builder [Xlsxrb::WorkbookBuilder]
|
|
343
452
|
# @return [Elements::Workbook]
|
|
344
453
|
# @api public
|
|
345
|
-
# : (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } ->
|
|
346
|
-
def self.build: (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } ->
|
|
454
|
+
# : (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } -> Elements::Workbook
|
|
455
|
+
def self.build: (?strict_excel_mode: bool) ?{ (WorkbookBuilder) -> void } -> Elements::Workbook
|
|
347
456
|
|
|
348
457
|
# DSL context for Xlsxrb.build.
|
|
349
458
|
# @api public
|
|
@@ -452,9 +561,12 @@ module Xlsxrb
|
|
|
452
561
|
# : (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
|
|
453
562
|
def custom_property: (String name, String | Integer | Float | bool | Time value, ?type: ::Symbol) -> void
|
|
454
563
|
|
|
564
|
+
# Builds and returns the in-memory Elements::Workbook.
|
|
565
|
+
#
|
|
566
|
+
# @return [Elements::Workbook]
|
|
455
567
|
# @api public
|
|
456
|
-
# : () ->
|
|
457
|
-
def build: () ->
|
|
568
|
+
# : () -> Elements::Workbook
|
|
569
|
+
def build: () -> Elements::Workbook
|
|
458
570
|
|
|
459
571
|
private
|
|
460
572
|
|
|
@@ -607,8 +719,8 @@ module Xlsxrb
|
|
|
607
719
|
# @param items [Array, nil] Items configuration.
|
|
608
720
|
# @return [void]
|
|
609
721
|
# @api public
|
|
610
|
-
# : (untyped source_ref, **untyped opts) -> void
|
|
611
|
-
def pivot_table: (untyped source_ref, **untyped opts) -> void
|
|
722
|
+
# : (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
|
|
723
|
+
def pivot_table: (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
|
|
612
724
|
|
|
613
725
|
# Add a comment on a cell.
|
|
614
726
|
#
|
|
@@ -627,8 +739,8 @@ module Xlsxrb
|
|
|
627
739
|
# @param opts [Hash] Additional options.
|
|
628
740
|
# @return [void]
|
|
629
741
|
# @api public
|
|
630
|
-
# : (**untyped opts) -> void
|
|
631
|
-
def sparkline_group: (**untyped opts) -> void
|
|
742
|
+
# : (sparklines: untyped, ?type: untyped, **untyped opts) -> void
|
|
743
|
+
def sparkline_group: (sparklines: untyped, ?type: untyped, **untyped opts) -> void
|
|
632
744
|
|
|
633
745
|
# Merge a range of cells (e.g. "A1:B2"), or by coordinate indices.
|
|
634
746
|
#
|
|
@@ -748,9 +860,12 @@ module Xlsxrb
|
|
|
748
860
|
# : (Integer | String col_index) -> void
|
|
749
861
|
def page_break_col: (Integer | String col_index) -> void
|
|
750
862
|
|
|
863
|
+
# Builds and returns the in-memory Elements::Worksheet.
|
|
864
|
+
#
|
|
865
|
+
# @return [Elements::Worksheet]
|
|
751
866
|
# @api public
|
|
752
|
-
# : () ->
|
|
753
|
-
def build: () ->
|
|
867
|
+
# : () -> Elements::Worksheet
|
|
868
|
+
def build: () -> Elements::Worksheet
|
|
754
869
|
|
|
755
870
|
# Internal: returns styles for later processing by WorkbookBuilder
|
|
756
871
|
# : untyped
|
|
@@ -792,247 +907,544 @@ module Xlsxrb
|
|
|
792
907
|
class WorksheetProxy
|
|
793
908
|
def initialize: (untyped writer, untyped sheet_name) -> untyped
|
|
794
909
|
|
|
795
|
-
#
|
|
796
|
-
#
|
|
910
|
+
# Define or configure a named cell style.
|
|
911
|
+
#
|
|
912
|
+
# @example
|
|
913
|
+
# s.style(:header, bold: true, fill_color: "4F81BD", font_color: "FFFFFF")
|
|
914
|
+
#
|
|
915
|
+
# @param name [String, Symbol] The name of the style.
|
|
916
|
+
# @param opts [Hash] Style options (e.g. bold: true, fill_color: "FF0000").
|
|
917
|
+
# @yield [style_builder]
|
|
918
|
+
# @yieldparam style_builder [Xlsxrb::StyleBuilder]
|
|
919
|
+
# @return [Xlsxrb::StyleBuilder]
|
|
797
920
|
# @api public
|
|
798
|
-
# : (
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
#
|
|
804
|
-
#
|
|
921
|
+
# : (String | Symbol name, **untyped opts) ?{ (Xlsxrb::StyleBuilder) -> void } -> Xlsxrb::StyleBuilder
|
|
922
|
+
def style: (String | Symbol name, **untyped opts) ?{ (Xlsxrb::StyleBuilder) -> void } -> Xlsxrb::StyleBuilder
|
|
923
|
+
|
|
924
|
+
# Merge a range of cells.
|
|
925
|
+
#
|
|
926
|
+
# @example Merge with cell reference string
|
|
927
|
+
# s.merge("A1:C1")
|
|
928
|
+
#
|
|
929
|
+
# @example Merge with coordinates
|
|
930
|
+
# s.merge(row: 0, col_start: 0, col_end: 2)
|
|
931
|
+
#
|
|
932
|
+
# @param range [String, nil] The cell range (e.g. "A1:B2").
|
|
933
|
+
# @param row [Integer, nil] 0-based row index.
|
|
934
|
+
# @param col_start [Integer, String, nil] 0-based start column index or letter.
|
|
935
|
+
# @param col_end [Integer, String, nil] 0-based end column index or letter.
|
|
936
|
+
# @param row_start [Integer, nil] 0-based start row index.
|
|
937
|
+
# @param row_end [Integer, nil] 0-based end row index.
|
|
938
|
+
# @return [void]
|
|
805
939
|
# @api public
|
|
806
|
-
# : (
|
|
807
|
-
def merge: (
|
|
808
|
-
|
|
809
|
-
#
|
|
810
|
-
#
|
|
940
|
+
# : (?String? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void
|
|
941
|
+
def merge: (?String? range, ?row: Integer | nil, ?col_start: (Integer | String)?, ?col_end: (Integer | String)?, ?row_start: Integer | nil, ?row_end: Integer | nil) -> void
|
|
942
|
+
|
|
943
|
+
# Add a drawing shape to the sheet.
|
|
944
|
+
#
|
|
945
|
+
# @example
|
|
946
|
+
# s.shape(preset: "ellipse", text: "Circle", from_col: 1, from_row: 1, to_col: 4, to_row: 5)
|
|
947
|
+
#
|
|
948
|
+
# @param preset [String] Preset shape type (e.g. "rect", "ellipse").
|
|
949
|
+
# @param text [String, nil] Shape label text.
|
|
950
|
+
# @param from_col [Integer] Starting column index (0-based).
|
|
951
|
+
# @param from_row [Integer] Starting row index (0-based).
|
|
952
|
+
# @param to_col [Integer] Ending column index (0-based).
|
|
953
|
+
# @param to_row [Integer] Ending row index (0-based).
|
|
954
|
+
# @param opts [Hash] Additional shape formatting options.
|
|
955
|
+
# @return [void]
|
|
811
956
|
# @api public
|
|
812
|
-
# : (
|
|
813
|
-
def shape: (
|
|
957
|
+
# : (?preset: String, ?text: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
|
|
958
|
+
def shape: (?preset: String, ?text: String?, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
|
|
814
959
|
|
|
815
|
-
#
|
|
816
|
-
#
|
|
817
|
-
# @api public
|
|
960
|
+
# simplecov:disable
|
|
961
|
+
# Edge case / untested delegation block
|
|
818
962
|
# : (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
|
|
819
963
|
def internal_sheet_setup: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
|
|
820
964
|
|
|
821
|
-
#
|
|
822
|
-
#
|
|
965
|
+
# Add a row to the active sheet.
|
|
966
|
+
#
|
|
967
|
+
# @example Write an array of values
|
|
968
|
+
# s.row(["Name", "Age", "City"])
|
|
969
|
+
#
|
|
970
|
+
# @example Write with explicit column keys and styles
|
|
971
|
+
# s.row({ A: "Header", C: 100 }, styles: { A: :bold })
|
|
972
|
+
#
|
|
973
|
+
# @param values [Array, Hash] The cell values (e.g. `[1, 2, 3]` or `{ A: 1, C: 3 }`).
|
|
974
|
+
# @param styles [String, Symbol, Array, Hash, nil] Style names or hashes to apply.
|
|
975
|
+
# @param height [Float, Integer, nil] The row height in points (0 - 409).
|
|
976
|
+
# @param hidden [Boolean] Whether the row is hidden.
|
|
977
|
+
# @param custom_height [Boolean] Whether to flag as custom height.
|
|
978
|
+
# @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
|
|
979
|
+
# @return [void]
|
|
823
980
|
# @api public
|
|
824
|
-
# : (
|
|
825
|
-
def row: (
|
|
826
|
-
|
|
827
|
-
#
|
|
828
|
-
#
|
|
981
|
+
# : (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
|
|
982
|
+
def row: (Array[untyped] | Hash[untyped, untyped] values, ?styles: untyped, ?height: Float | Integer | nil, ?hidden: bool, ?custom_height: bool, ?outline_level: Integer | nil) -> void
|
|
983
|
+
|
|
984
|
+
# Configure column width and properties.
|
|
985
|
+
#
|
|
986
|
+
# @example Set column A width
|
|
987
|
+
# s.column(0, width: 25.0)
|
|
988
|
+
#
|
|
989
|
+
# @param col_index [Integer, String, Symbol] 0-based column index or letter (e.g. 0 or "A" or :A).
|
|
990
|
+
# @param width [Float, Integer, nil] Column width in characters.
|
|
991
|
+
# @param hidden [Boolean] Whether the column is hidden.
|
|
992
|
+
# @param best_fit [Boolean] Whether the column automatically fits content.
|
|
993
|
+
# @param custom_width [Boolean] Whether to flag as custom width.
|
|
994
|
+
# @param outline_level [Integer, nil] Grouping/outline level (0 - 7).
|
|
995
|
+
# @param collapsed [Boolean] Whether the outline group is collapsed.
|
|
996
|
+
# @return [void]
|
|
829
997
|
# @api public
|
|
830
|
-
# : (
|
|
831
|
-
def column: (
|
|
832
|
-
|
|
833
|
-
#
|
|
834
|
-
#
|
|
998
|
+
# : (Integer | String | Symbol col_index, ?width: Float | Integer | nil, ?hidden: bool, ?best_fit: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool) -> void
|
|
999
|
+
def column: (Integer | String | Symbol col_index, ?width: Float | Integer | nil, ?hidden: bool, ?best_fit: bool, ?custom_width: bool, ?outline_level: Integer | nil, ?collapsed: bool) -> void
|
|
1000
|
+
|
|
1001
|
+
# Add a chart to the sheet.
|
|
1002
|
+
#
|
|
1003
|
+
# @example
|
|
1004
|
+
# s.chart(:bar) do |chart_builder|
|
|
1005
|
+
# chart_builder.title("Quarterly Sales")
|
|
1006
|
+
# chart_builder.series(values: "Sheet1!$B$2:$B$5", categories: "Sheet1!$A$2:$A$5", name: "Revenue")
|
|
1007
|
+
# end
|
|
1008
|
+
#
|
|
1009
|
+
# @param type [Symbol, String, nil] The chart type (:bar, :col, :line, :pie, :scatter, :area, :doughnut, :radar).
|
|
1010
|
+
# @param opts [Hash] Additional chart options.
|
|
1011
|
+
# @yield [chart_builder]
|
|
1012
|
+
# @yieldparam chart_builder [Xlsxrb::ChartBuilder]
|
|
1013
|
+
# @return [void]
|
|
835
1014
|
# @api public
|
|
836
|
-
# : (
|
|
837
|
-
def chart: (
|
|
838
|
-
|
|
839
|
-
#
|
|
840
|
-
#
|
|
841
|
-
# @
|
|
842
|
-
#
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
#
|
|
846
|
-
#
|
|
1015
|
+
# : (?Symbol | String? type, **untyped opts) ?{ (Xlsxrb::ChartBuilder) -> void } -> void
|
|
1016
|
+
def chart: (?Symbol | String? type, **untyped opts) ?{ (Xlsxrb::ChartBuilder) -> void } -> void
|
|
1017
|
+
|
|
1018
|
+
# Add a hyperlink to a cell.
|
|
1019
|
+
#
|
|
1020
|
+
# @example Positional URL
|
|
1021
|
+
# s.hyperlink("A1", "https://example.com", display: "Example")
|
|
1022
|
+
#
|
|
1023
|
+
# @example Keyword location
|
|
1024
|
+
# s.hyperlink("A1", location: "https://example.com", tooltip: "Go to Example")
|
|
1025
|
+
#
|
|
1026
|
+
# @param cell [String] The cell reference (e.g. "A1").
|
|
1027
|
+
# @param url [String, nil] The target URL or URI.
|
|
1028
|
+
# @param display [String, nil] Display text for the link.
|
|
1029
|
+
# @param tooltip [String, nil] Tooltip text when hovering.
|
|
1030
|
+
# @param location [String, nil] Destination location / URL (keyword alternative).
|
|
1031
|
+
# @return [void]
|
|
847
1032
|
# @api public
|
|
848
|
-
# : (
|
|
849
|
-
def
|
|
850
|
-
|
|
851
|
-
#
|
|
852
|
-
#
|
|
1033
|
+
# : (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
|
|
1034
|
+
def hyperlink: (String cell, ?String? url, ?display: String?, ?tooltip: String?, ?location: String?) -> void
|
|
1035
|
+
|
|
1036
|
+
# Set the auto-filter range on the sheet.
|
|
1037
|
+
#
|
|
1038
|
+
# @example
|
|
1039
|
+
# s.auto_filter("A1:D100")
|
|
1040
|
+
#
|
|
1041
|
+
# @param ref [String] The cell range (e.g. "A1:D10").
|
|
1042
|
+
# @return [void]
|
|
853
1043
|
# @api public
|
|
854
|
-
# : (
|
|
855
|
-
def
|
|
856
|
-
|
|
857
|
-
#
|
|
858
|
-
#
|
|
1044
|
+
# : (String ref) -> void
|
|
1045
|
+
def auto_filter: (String ref) -> void
|
|
1046
|
+
|
|
1047
|
+
# Set filter criteria for a column in the auto-filter.
|
|
1048
|
+
#
|
|
1049
|
+
# @example Simple values filter
|
|
1050
|
+
# s.filter_column(0, ["Active", "Pending"])
|
|
1051
|
+
#
|
|
1052
|
+
# @example Custom filter specification
|
|
1053
|
+
# s.filter_column(0, { type: :filters, values: ["Data"] })
|
|
1054
|
+
#
|
|
1055
|
+
# @param col_id [Integer] 0-based column index relative to auto-filter range.
|
|
1056
|
+
# @param filter_values [Array<String>, Hash] Values or filter specification hash.
|
|
1057
|
+
# @return [void]
|
|
859
1058
|
# @api public
|
|
860
|
-
# : (
|
|
861
|
-
def
|
|
862
|
-
|
|
863
|
-
#
|
|
864
|
-
#
|
|
1059
|
+
# : (Integer col_id, Array[String] | Hash[Symbol, untyped] filter_values) -> void
|
|
1060
|
+
def filter_column: (Integer col_id, Array[String] | Hash[Symbol, untyped] filter_values) -> void
|
|
1061
|
+
|
|
1062
|
+
# Configure sort state on a range.
|
|
1063
|
+
#
|
|
1064
|
+
# @example
|
|
1065
|
+
# s.sort_state("A1:A10", [{ ref: "A1:A10", descending: true }])
|
|
1066
|
+
#
|
|
1067
|
+
# @param ref [String] The range to sort.
|
|
1068
|
+
# @param sort_conditions [Array<Hash>, Hash] Sort conditions array or options hash.
|
|
1069
|
+
# @param opts [Hash] Additional sort options.
|
|
1070
|
+
# @return [void]
|
|
865
1071
|
# @api public
|
|
866
|
-
# : (
|
|
867
|
-
def
|
|
868
|
-
|
|
869
|
-
#
|
|
870
|
-
#
|
|
1072
|
+
# : (String ref, Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped] sort_conditions, **untyped opts) -> void
|
|
1073
|
+
def sort_state: (String ref, Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped] sort_conditions, **untyped opts) -> void
|
|
1074
|
+
|
|
1075
|
+
# Add data validation rules to a range.
|
|
1076
|
+
#
|
|
1077
|
+
# @example Dropdown list validation
|
|
1078
|
+
# s.validate_data("B2:B100", type: "list", formula1: '"High,Medium,Low"')
|
|
1079
|
+
#
|
|
1080
|
+
# @example Integer range validation
|
|
1081
|
+
# s.validate_data("C2:C100", type: "whole", operator: "between", formula1: 1, formula2: 100)
|
|
1082
|
+
#
|
|
1083
|
+
# @param range [String] The cell range (e.g. "B2:B10").
|
|
1084
|
+
# @param type [String, Symbol] Validation type ("list", "whole", "decimal", "date", "time", "textLength", "custom").
|
|
1085
|
+
# @param opts [Hash] Validation options.
|
|
1086
|
+
# @return [void]
|
|
871
1087
|
# @api public
|
|
872
|
-
# : (
|
|
873
|
-
def
|
|
874
|
-
|
|
875
|
-
#
|
|
876
|
-
#
|
|
1088
|
+
# : (String range, ?type: String | Symbol, **untyped opts) -> void
|
|
1089
|
+
def validate_data: (String range, ?type: String | Symbol, **untyped opts) -> void
|
|
1090
|
+
|
|
1091
|
+
# Add conditional formatting to a range.
|
|
1092
|
+
#
|
|
1093
|
+
# @example Highlight values greater than 100
|
|
1094
|
+
# s.conditional_format("A1:A10", type: "cellIs", operator: "greaterThan", formula: 100, style: :highlight)
|
|
1095
|
+
#
|
|
1096
|
+
# @param range [String] The cell range (e.g. "A1:A10").
|
|
1097
|
+
# @param type [String, Symbol] Rule type ("cellIs", "colorScale", "dataBar", "expression").
|
|
1098
|
+
# @param opts [Hash] Rule options.
|
|
1099
|
+
# @return [void]
|
|
877
1100
|
# @api public
|
|
878
|
-
# : (
|
|
879
|
-
def
|
|
880
|
-
|
|
881
|
-
#
|
|
882
|
-
#
|
|
1101
|
+
# : (String range, ?type: String | Symbol, **untyped opts) -> void
|
|
1102
|
+
def conditional_format: (String range, ?type: String | Symbol, **untyped opts) -> void
|
|
1103
|
+
|
|
1104
|
+
# Add a formatted Excel Table to the sheet.
|
|
1105
|
+
#
|
|
1106
|
+
# @example
|
|
1107
|
+
# s.table("A1:C10", columns: ["ID", "Name", "Total"], name: "SalesTable", style: "TableStyleMedium9")
|
|
1108
|
+
#
|
|
1109
|
+
# @param ref [String] The cell range for the table (e.g. "A1:D10").
|
|
1110
|
+
# @param columns [Array<String>, Array<Hash>] Column names or definitions.
|
|
1111
|
+
# @param name [String, nil] Table name.
|
|
1112
|
+
# @param display_name [String, nil] Display name.
|
|
1113
|
+
# @param style [String, nil] Table style name.
|
|
1114
|
+
# @param opts [Hash] Additional options.
|
|
1115
|
+
# @return [void]
|
|
883
1116
|
# @api public
|
|
884
|
-
# : (
|
|
885
|
-
def
|
|
1117
|
+
# : (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void
|
|
1118
|
+
def table: (String ref, columns: untyped, ?name: String?, ?display_name: String?, ?style: String?, **untyped opts) -> void
|
|
886
1119
|
|
|
887
|
-
#
|
|
888
|
-
#
|
|
1120
|
+
# simplecov:disable
|
|
1121
|
+
# Edge case / untested delegation block
|
|
1122
|
+
# : () -> void
|
|
1123
|
+
def cleanup!: () -> void
|
|
1124
|
+
|
|
1125
|
+
# Add a comment to a cell.
|
|
1126
|
+
#
|
|
1127
|
+
# @example
|
|
1128
|
+
# s.comment("A1", "Reviewed and approved", author: "Auditor")
|
|
1129
|
+
#
|
|
1130
|
+
# @param cell [String, Integer] The cell reference (e.g. "A1").
|
|
1131
|
+
# @param text [String] The comment text.
|
|
1132
|
+
# @param author [String] The author name.
|
|
1133
|
+
# @return [void]
|
|
889
1134
|
# @api public
|
|
890
|
-
# : (
|
|
891
|
-
def comment: (
|
|
892
|
-
|
|
893
|
-
#
|
|
894
|
-
#
|
|
1135
|
+
# : (String | Integer cell, String text, ?author: String) -> void
|
|
1136
|
+
def comment: (String | Integer cell, String text, ?author: String) -> void
|
|
1137
|
+
|
|
1138
|
+
# Add a Pivot Table to the sheet.
|
|
1139
|
+
#
|
|
1140
|
+
# @example
|
|
1141
|
+
# s.pivot_table("Sheet1!A1:D100", row_fields: ["Category"], data_fields: ["Amount"], dest_ref: "F1")
|
|
1142
|
+
#
|
|
1143
|
+
# @param source_ref [String] Source data range reference (e.g. "Sheet1!A1:D100").
|
|
1144
|
+
# @param row_fields [Array<String>] Field names for rows.
|
|
1145
|
+
# @param data_fields [Array<String>] Field names for data values.
|
|
1146
|
+
# @param col_fields [Array<String>] Field names for columns.
|
|
1147
|
+
# @param dest_ref [String] Target top-left cell reference (default: "E1").
|
|
1148
|
+
# @param name [String, nil] Pivot table name.
|
|
1149
|
+
# @param field_names [Array<String>, nil] Override field names.
|
|
1150
|
+
# @param items [Array, nil] Items configuration.
|
|
1151
|
+
# @param opts [Hash] Additional options.
|
|
1152
|
+
# @return [void]
|
|
895
1153
|
# @api public
|
|
896
|
-
# : (
|
|
897
|
-
def pivot_table: (
|
|
898
|
-
|
|
899
|
-
#
|
|
900
|
-
#
|
|
1154
|
+
# : (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
|
|
1155
|
+
def pivot_table: (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
|
|
1156
|
+
|
|
1157
|
+
# Add sparklines to the sheet.
|
|
1158
|
+
#
|
|
1159
|
+
# @example
|
|
1160
|
+
# s.sparkline_group(sparklines: [{ data_ref: "A1:E1", location_ref: "F1" }], type: "line")
|
|
1161
|
+
#
|
|
1162
|
+
# @param sparklines [Array<Hash>] Array of { data_ref:, location_ref: } hashes.
|
|
1163
|
+
# @param type [String, nil] "line" (default), "column", or "stacked".
|
|
1164
|
+
# @param opts [Hash] Additional sparkline options.
|
|
1165
|
+
# @return [void]
|
|
901
1166
|
# @api public
|
|
902
|
-
# : (
|
|
903
|
-
def sparkline_group: (
|
|
1167
|
+
# : (sparklines: Array[Hash[Symbol, untyped]], ?type: String?, **untyped opts) -> void
|
|
1168
|
+
def sparkline_group: (sparklines: Array[Hash[Symbol, untyped]], ?type: String?, **untyped opts) -> void
|
|
904
1169
|
|
|
905
|
-
#
|
|
906
|
-
#
|
|
1170
|
+
# Set workbook-level properties.
|
|
1171
|
+
#
|
|
1172
|
+
# @param opts [Hash] Workbook property options.
|
|
1173
|
+
# @return [void]
|
|
907
1174
|
# @api public
|
|
908
|
-
# : (
|
|
909
|
-
def workbook_property: (
|
|
910
|
-
|
|
911
|
-
#
|
|
912
|
-
#
|
|
1175
|
+
# : (**untyped opts) -> void
|
|
1176
|
+
def workbook_property: (**untyped opts) -> void
|
|
1177
|
+
|
|
1178
|
+
# Set sheet properties (e.g. tab color, page setup flags).
|
|
1179
|
+
#
|
|
1180
|
+
# @example
|
|
1181
|
+
# s.sheet_properties(:tab_color, "FF0000")
|
|
1182
|
+
#
|
|
1183
|
+
# @param name [Symbol, String] Property name.
|
|
1184
|
+
# @param value [Object] Property value.
|
|
1185
|
+
# @return [void]
|
|
913
1186
|
# @api public
|
|
914
|
-
# : (
|
|
915
|
-
def sheet_properties: (
|
|
916
|
-
|
|
917
|
-
#
|
|
918
|
-
#
|
|
1187
|
+
# : (Symbol | String name, untyped value) -> void
|
|
1188
|
+
def sheet_properties: (Symbol | String name, untyped value) -> void
|
|
1189
|
+
|
|
1190
|
+
# Add a defined named range or formula.
|
|
1191
|
+
#
|
|
1192
|
+
# @example
|
|
1193
|
+
# s.defined_name("TaxRate", "0.10")
|
|
1194
|
+
#
|
|
1195
|
+
# @param name [String] The name.
|
|
1196
|
+
# @param formula [String] The formula or range expression.
|
|
1197
|
+
# @param sheet_id [Integer, nil] Optional sheet scope.
|
|
1198
|
+
# @param hidden [Boolean] Whether the name is hidden.
|
|
1199
|
+
# @return [void]
|
|
919
1200
|
# @api public
|
|
920
|
-
# : (
|
|
921
|
-
def defined_name: (
|
|
922
|
-
|
|
923
|
-
#
|
|
924
|
-
#
|
|
1201
|
+
# : (String name, String formula, ?sheet_id: Integer | nil, ?hidden: bool) -> void
|
|
1202
|
+
def defined_name: (String name, String formula, ?sheet_id: Integer | nil, ?hidden: bool) -> void
|
|
1203
|
+
|
|
1204
|
+
# Freeze rows and/or columns for scrolling.
|
|
1205
|
+
#
|
|
1206
|
+
# @example Freeze top row
|
|
1207
|
+
# s.freeze_pane(row: 1)
|
|
1208
|
+
#
|
|
1209
|
+
# @example Freeze first column and top 2 rows
|
|
1210
|
+
# s.freeze_pane(row: 2, col: 1)
|
|
1211
|
+
#
|
|
1212
|
+
# @param row [Integer, nil] Number of rows to freeze.
|
|
1213
|
+
# @param col [Integer, nil] Number of columns to freeze.
|
|
1214
|
+
# @return [void]
|
|
925
1215
|
# @api public
|
|
926
|
-
# : (
|
|
927
|
-
def freeze_pane: (
|
|
928
|
-
|
|
929
|
-
#
|
|
930
|
-
#
|
|
1216
|
+
# : (?row: Integer | nil, ?col: Integer | nil) -> void
|
|
1217
|
+
def freeze_pane: (?row: Integer | nil, ?col: Integer | nil) -> void
|
|
1218
|
+
|
|
1219
|
+
# simplecov:disable
|
|
1220
|
+
# Edge case / untested delegation block
|
|
1221
|
+
# Set the print area range for the sheet.
|
|
1222
|
+
#
|
|
1223
|
+
# @example
|
|
1224
|
+
# s.print_area("A1:G50")
|
|
1225
|
+
#
|
|
1226
|
+
# @param ref [String] Range reference.
|
|
1227
|
+
# @return [void]
|
|
931
1228
|
# @api public
|
|
932
|
-
# : (
|
|
933
|
-
def print_area: (
|
|
934
|
-
|
|
935
|
-
#
|
|
936
|
-
#
|
|
1229
|
+
# : (String ref) -> void
|
|
1230
|
+
def print_area: (String ref) -> void
|
|
1231
|
+
|
|
1232
|
+
# simplecov:disable
|
|
1233
|
+
# Edge case / untested delegation block
|
|
1234
|
+
# Configure repeating title rows and columns for printing.
|
|
1235
|
+
#
|
|
1236
|
+
# @example Repeat top 2 rows on every page
|
|
1237
|
+
# s.print_titles(rows: "1:2")
|
|
1238
|
+
#
|
|
1239
|
+
# @param rows [String, nil] Row range to repeat (e.g. "1:2").
|
|
1240
|
+
# @param cols [String, nil] Column range to repeat (e.g. "A:B").
|
|
1241
|
+
# @return [void]
|
|
937
1242
|
# @api public
|
|
938
|
-
# : (
|
|
939
|
-
def print_titles: (
|
|
940
|
-
|
|
941
|
-
#
|
|
942
|
-
#
|
|
1243
|
+
# : (?rows: String?, ?cols: String?) -> void
|
|
1244
|
+
def print_titles: (?rows: String?, ?cols: String?) -> void
|
|
1245
|
+
|
|
1246
|
+
# Split sheet view into panes.
|
|
1247
|
+
#
|
|
1248
|
+
# @param x_split [Numeric, nil] Horizontal split position.
|
|
1249
|
+
# @param y_split [Numeric, nil] Vertical split position.
|
|
1250
|
+
# @param top_left_cell [String, nil] Top-left visible cell in bottom-right pane.
|
|
1251
|
+
# @param active_pane [String, nil] Active pane identifier.
|
|
1252
|
+
# @param state [String, nil] Split state.
|
|
1253
|
+
# @return [void]
|
|
943
1254
|
# @api public
|
|
944
|
-
# : (
|
|
945
|
-
def split_pane: (
|
|
946
|
-
|
|
947
|
-
#
|
|
948
|
-
#
|
|
1255
|
+
# : (?x_split: Numeric | nil, ?y_split: Numeric | nil, ?top_left_cell: String?, ?active_pane: String?, ?state: String?) -> void
|
|
1256
|
+
def split_pane: (?x_split: Numeric | nil, ?y_split: Numeric | nil, ?top_left_cell: String?, ?active_pane: String?, ?state: String?) -> void
|
|
1257
|
+
|
|
1258
|
+
# simplecov:disable
|
|
1259
|
+
# Edge case / untested delegation block
|
|
1260
|
+
# Protect the workbook structure.
|
|
1261
|
+
#
|
|
1262
|
+
# @param opts [Hash] Protection options.
|
|
1263
|
+
# @return [void]
|
|
949
1264
|
# @api public
|
|
950
|
-
# : (
|
|
951
|
-
def protect_workbook: (
|
|
952
|
-
|
|
953
|
-
#
|
|
954
|
-
#
|
|
1265
|
+
# : (**untyped opts) -> void
|
|
1266
|
+
def protect_workbook: (**untyped opts) -> void
|
|
1267
|
+
|
|
1268
|
+
# simplecov:disable
|
|
1269
|
+
# Edge case / untested delegation block
|
|
1270
|
+
# Set core metadata property.
|
|
1271
|
+
#
|
|
1272
|
+
# @param name [String, Symbol] Property name.
|
|
1273
|
+
# @param value [Object] Property value.
|
|
1274
|
+
# @return [void]
|
|
955
1275
|
# @api public
|
|
956
|
-
# : (
|
|
957
|
-
def core_property: (
|
|
958
|
-
|
|
959
|
-
#
|
|
960
|
-
#
|
|
1276
|
+
# : (String | Symbol name, untyped value) -> void
|
|
1277
|
+
def core_property: (String | Symbol name, untyped value) -> void
|
|
1278
|
+
|
|
1279
|
+
# Set the active/selected cell on the sheet.
|
|
1280
|
+
#
|
|
1281
|
+
# @example
|
|
1282
|
+
# s.select_cell("B5")
|
|
1283
|
+
# s.select_cell("A1", sqref: "A1:A2", pane: "topRight")
|
|
1284
|
+
#
|
|
1285
|
+
# @param active_cell [String] Cell reference (e.g. "A1").
|
|
1286
|
+
# @param sqref [String, nil] Selection range.
|
|
1287
|
+
# @param pane [String, Symbol, nil] Pane identifier.
|
|
1288
|
+
# @return [void]
|
|
961
1289
|
# @api public
|
|
962
|
-
# : (
|
|
963
|
-
def select_cell: (
|
|
964
|
-
|
|
965
|
-
#
|
|
966
|
-
#
|
|
1290
|
+
# : (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
1291
|
+
def select_cell: (String active_cell, ?sqref: String?, ?pane: (String | Symbol)?) -> void
|
|
1292
|
+
|
|
1293
|
+
# Configure page margins for printing.
|
|
1294
|
+
#
|
|
1295
|
+
# @example
|
|
1296
|
+
# s.page_margins(left: 0.7, right: 0.7, top: 0.75, bottom: 0.75)
|
|
1297
|
+
#
|
|
1298
|
+
# @param left [Float, nil] Left margin in inches.
|
|
1299
|
+
# @param right [Float, nil] Right margin in inches.
|
|
1300
|
+
# @param top [Float, nil] Top margin in inches.
|
|
1301
|
+
# @param bottom [Float, nil] Bottom margin in inches.
|
|
1302
|
+
# @param header [Float, nil] Header margin in inches.
|
|
1303
|
+
# @param footer [Float, nil] Footer margin in inches.
|
|
1304
|
+
# @return [void]
|
|
967
1305
|
# @api public
|
|
968
|
-
# : (
|
|
969
|
-
def page_margins: (
|
|
970
|
-
|
|
971
|
-
#
|
|
972
|
-
#
|
|
1306
|
+
# : (?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) -> void
|
|
1307
|
+
def page_margins: (?left: Float | nil, ?right: Float | nil, ?top: Float | nil, ?bottom: Float | nil, ?header: Float | nil, ?footer: Float | nil) -> void
|
|
1308
|
+
|
|
1309
|
+
# Configure page orientation, paper size, and print setup.
|
|
1310
|
+
#
|
|
1311
|
+
# @example Landscape A4
|
|
1312
|
+
# s.page_setup(orientation: "landscape", paper_size: 9)
|
|
1313
|
+
#
|
|
1314
|
+
# @param orientation [String, Symbol, nil] "portrait" or "landscape" (or :portrait, :landscape).
|
|
1315
|
+
# @param paper_size [Integer, nil] Paper size index (e.g. 9 for A4, 1 for Letter).
|
|
1316
|
+
# @param opts [Hash] Additional options (scale, fit_to_width, fit_to_height).
|
|
1317
|
+
# @return [void]
|
|
973
1318
|
# @api public
|
|
974
|
-
# : (
|
|
975
|
-
def page_setup: (
|
|
976
|
-
|
|
977
|
-
#
|
|
978
|
-
#
|
|
1319
|
+
# : (?orientation: (String | Symbol)?, ?paper_size: Integer | nil, **untyped opts) -> void
|
|
1320
|
+
def page_setup: (?orientation: (String | Symbol)?, ?paper_size: Integer | nil, **untyped opts) -> void
|
|
1321
|
+
|
|
1322
|
+
# Configure header and footer text for printing.
|
|
1323
|
+
#
|
|
1324
|
+
# @example
|
|
1325
|
+
# s.header_footer(odd_header: "&CConfidential", odd_footer: "&RPage &P of &N")
|
|
1326
|
+
#
|
|
1327
|
+
# @param opts [Hash] Header and footer specifications.
|
|
1328
|
+
# @return [void]
|
|
979
1329
|
# @api public
|
|
980
|
-
# : (
|
|
981
|
-
def header_footer: (
|
|
982
|
-
|
|
983
|
-
#
|
|
984
|
-
#
|
|
1330
|
+
# : (**untyped opts) -> void
|
|
1331
|
+
def header_footer: (**untyped opts) -> void
|
|
1332
|
+
|
|
1333
|
+
# Configure print options (e.g. gridlines, headings).
|
|
1334
|
+
#
|
|
1335
|
+
# @example
|
|
1336
|
+
# s.print_options(:grid_lines, true)
|
|
1337
|
+
#
|
|
1338
|
+
# @param name [Symbol, String] Print option name.
|
|
1339
|
+
# @param value [Object] Print option value.
|
|
1340
|
+
# @return [void]
|
|
985
1341
|
# @api public
|
|
986
|
-
# : (
|
|
987
|
-
def print_options: (
|
|
988
|
-
|
|
989
|
-
#
|
|
990
|
-
#
|
|
1342
|
+
# : (Symbol | String name, untyped value) -> void
|
|
1343
|
+
def print_options: (Symbol | String name, untyped value) -> void
|
|
1344
|
+
|
|
1345
|
+
# simplecov:disable
|
|
1346
|
+
# Edge case / untested delegation block
|
|
1347
|
+
# Set document metadata properties (core, app, custom).
|
|
1348
|
+
#
|
|
1349
|
+
# @example
|
|
1350
|
+
# s.properties(core: { title: "Report", creator: "App" })
|
|
1351
|
+
#
|
|
1352
|
+
# @param core [Hash, nil] Core properties (title, creator, subject, etc.).
|
|
1353
|
+
# @param app [Hash, nil] App properties (company, manager).
|
|
1354
|
+
# @param custom [Hash, nil] Custom properties.
|
|
1355
|
+
# @return [void]
|
|
991
1356
|
# @api public
|
|
992
|
-
# : (
|
|
993
|
-
def properties: (
|
|
994
|
-
|
|
995
|
-
#
|
|
996
|
-
#
|
|
1357
|
+
# : (?core: Hash[untyped, untyped]?, ?app: Hash[untyped, untyped]?, ?custom: Hash[untyped, untyped]?) -> void
|
|
1358
|
+
def properties: (?core: Hash[untyped, untyped]?, ?app: Hash[untyped, untyped]?, ?custom: Hash[untyped, untyped]?) -> void
|
|
1359
|
+
|
|
1360
|
+
# simplecov:disable
|
|
1361
|
+
# Edge case / untested delegation block
|
|
1362
|
+
# Set app metadata property.
|
|
1363
|
+
#
|
|
1364
|
+
# @param name [String, Symbol] Property name.
|
|
1365
|
+
# @param value [Object] Property value.
|
|
1366
|
+
# @return [void]
|
|
997
1367
|
# @api public
|
|
998
|
-
# : (
|
|
999
|
-
def app_property: (
|
|
1000
|
-
|
|
1001
|
-
#
|
|
1002
|
-
#
|
|
1368
|
+
# : (String | Symbol name, untyped value) -> void
|
|
1369
|
+
def app_property: (String | Symbol name, untyped value) -> void
|
|
1370
|
+
|
|
1371
|
+
# Protect the worksheet against modifications.
|
|
1372
|
+
#
|
|
1373
|
+
# @example
|
|
1374
|
+
# s.protect_sheet(password: "secret", select_locked_cells: true)
|
|
1375
|
+
#
|
|
1376
|
+
# @param opts [Hash] Protection options.
|
|
1377
|
+
# @return [void]
|
|
1003
1378
|
# @api public
|
|
1004
|
-
# : (
|
|
1005
|
-
def protect_sheet: (
|
|
1006
|
-
|
|
1007
|
-
#
|
|
1008
|
-
#
|
|
1379
|
+
# : (**untyped opts) -> void
|
|
1380
|
+
def protect_sheet: (**untyped opts) -> void
|
|
1381
|
+
|
|
1382
|
+
# simplecov:disable
|
|
1383
|
+
# Edge case / untested delegation block
|
|
1384
|
+
# Set custom metadata property.
|
|
1385
|
+
#
|
|
1386
|
+
# @param name [String, Symbol] Property name.
|
|
1387
|
+
# @param value [Object] Property value.
|
|
1388
|
+
# @return [void]
|
|
1009
1389
|
# @api public
|
|
1010
|
-
# : (
|
|
1011
|
-
def custom_property: (
|
|
1012
|
-
|
|
1013
|
-
#
|
|
1014
|
-
#
|
|
1390
|
+
# : (String | Symbol name, untyped value) -> void
|
|
1391
|
+
def custom_property: (String | Symbol name, untyped value) -> void
|
|
1392
|
+
|
|
1393
|
+
# Insert an image into the sheet.
|
|
1394
|
+
#
|
|
1395
|
+
# @example
|
|
1396
|
+
# s.image(File.read("logo.png"), ext: "png", from_col: 0, from_row: 0, to_col: 2, to_row: 3)
|
|
1397
|
+
#
|
|
1398
|
+
# @param file_data [String] Binary image data or file content.
|
|
1399
|
+
# @param ext [String] Image extension ("png", "jpeg", etc.).
|
|
1400
|
+
# @param from_col [Integer] Starting column index (0-based).
|
|
1401
|
+
# @param from_row [Integer] Starting row index (0-based).
|
|
1402
|
+
# @param to_col [Integer] Ending column index (0-based).
|
|
1403
|
+
# @param to_row [Integer] Ending row index (0-based).
|
|
1404
|
+
# @param opts [Hash] Additional anchor and sizing options.
|
|
1405
|
+
# @return [void]
|
|
1015
1406
|
# @api public
|
|
1016
|
-
# : (
|
|
1017
|
-
def image: (
|
|
1018
|
-
|
|
1019
|
-
#
|
|
1020
|
-
#
|
|
1407
|
+
# : (String file_data, ?ext: String, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
|
|
1408
|
+
def image: (String file_data, ?ext: String, ?from_col: Integer, ?from_row: Integer, ?to_col: Integer, ?to_row: Integer, **untyped opts) -> void
|
|
1409
|
+
|
|
1410
|
+
# Configure sheet view settings (zoom scale, grid lines visibility).
|
|
1411
|
+
#
|
|
1412
|
+
# @example
|
|
1413
|
+
# s.sheet_view(:show_grid_lines, false)
|
|
1414
|
+
# s.sheet_view(:zoom_scale, 120)
|
|
1415
|
+
#
|
|
1416
|
+
# @param name [Symbol, String] View setting name.
|
|
1417
|
+
# @param value [Object] View setting value.
|
|
1418
|
+
# @return [void]
|
|
1021
1419
|
# @api public
|
|
1022
|
-
# : (
|
|
1023
|
-
def sheet_view: (
|
|
1024
|
-
|
|
1025
|
-
#
|
|
1026
|
-
#
|
|
1420
|
+
# : (Symbol | String name, untyped value) -> void
|
|
1421
|
+
def sheet_view: (Symbol | String name, untyped value) -> void
|
|
1422
|
+
|
|
1423
|
+
# simplecov:disable
|
|
1424
|
+
# Edge case / untested delegation block
|
|
1425
|
+
# Add a horizontal page break after the given row index.
|
|
1426
|
+
#
|
|
1427
|
+
# @example
|
|
1428
|
+
# s.page_break_row(25)
|
|
1429
|
+
#
|
|
1430
|
+
# @param row_index [Integer] 0-based row index.
|
|
1431
|
+
# @return [void]
|
|
1027
1432
|
# @api public
|
|
1028
|
-
# : (
|
|
1029
|
-
def page_break_row: (
|
|
1030
|
-
|
|
1031
|
-
#
|
|
1032
|
-
#
|
|
1433
|
+
# : (Integer row_index) -> void
|
|
1434
|
+
def page_break_row: (Integer row_index) -> void
|
|
1435
|
+
|
|
1436
|
+
# simplecov:disable
|
|
1437
|
+
# Edge case / untested delegation block
|
|
1438
|
+
# Add a vertical page break after the given column index.
|
|
1439
|
+
#
|
|
1440
|
+
# @example
|
|
1441
|
+
# s.page_break_col(5)
|
|
1442
|
+
#
|
|
1443
|
+
# @param col_index [Integer] 0-based column index.
|
|
1444
|
+
# @return [void]
|
|
1033
1445
|
# @api public
|
|
1034
|
-
# : (
|
|
1035
|
-
def page_break_col: (
|
|
1446
|
+
# : (Integer col_index) -> void
|
|
1447
|
+
def page_break_col: (Integer col_index) -> void
|
|
1036
1448
|
end
|
|
1037
1449
|
|
|
1038
1450
|
# Add a new sheet.
|
|
@@ -1104,20 +1516,20 @@ module Xlsxrb
|
|
|
1104
1516
|
def conditional_format: (untyped sqref, **untyped opts) -> void
|
|
1105
1517
|
|
|
1106
1518
|
# --- Tables ---
|
|
1107
|
-
# : (untyped ref, **untyped opts) -> void
|
|
1108
|
-
def table: (untyped ref, **untyped opts) -> void
|
|
1519
|
+
# : (untyped ref, columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) -> void
|
|
1520
|
+
def table: (untyped ref, columns: untyped, ?name: untyped, ?display_name: untyped, ?style: untyped, **untyped opts) -> void
|
|
1109
1521
|
|
|
1110
1522
|
# --- Pivot Tables ---
|
|
1111
|
-
# : (untyped source_ref, **untyped opts) -> void
|
|
1112
|
-
def pivot_table: (untyped source_ref, **untyped opts) -> void
|
|
1523
|
+
# : (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
|
|
1524
|
+
def pivot_table: (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
|
|
1113
1525
|
|
|
1114
1526
|
# --- Comments ---
|
|
1115
1527
|
# : (String | Integer cell, String text, ?author: ::String) -> void
|
|
1116
1528
|
def comment: (String | Integer cell, String text, ?author: ::String) -> void
|
|
1117
1529
|
|
|
1118
1530
|
# --- Sparklines ---
|
|
1119
|
-
# : (**untyped opts) -> void
|
|
1120
|
-
def sparkline_group: (**untyped opts) -> void
|
|
1531
|
+
# : (sparklines: untyped, ?type: untyped, **untyped opts) -> void
|
|
1532
|
+
def sparkline_group: (sparklines: untyped, ?type: untyped, **untyped opts) -> void
|
|
1121
1533
|
|
|
1122
1534
|
# Merge a range of cells (e.g. "A1:B2"), or by coordinate indices.
|
|
1123
1535
|
#
|