xlsxrb 0.1.17 → 0.2.0
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 +256 -1
- data/README.md +111 -28
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +439 -139
- data/lib/xlsxrb/chart_builder.rb +540 -193
- data/lib/xlsxrb/dsl_helpers.rb +178 -73
- data/lib/xlsxrb/elements/cell.rb +197 -130
- data/lib/xlsxrb/elements/column.rb +88 -7
- data/lib/xlsxrb/elements/coordinate_access.rb +86 -59
- data/lib/xlsxrb/elements/image.rb +18 -19
- data/lib/xlsxrb/elements/metadata.rb +2379 -0
- data/lib/xlsxrb/elements/row.rb +84 -118
- data/lib/xlsxrb/elements/styles.rb +140 -90
- data/lib/xlsxrb/elements/types.rb +164 -22
- data/lib/xlsxrb/elements/workbook.rb +122 -140
- data/lib/xlsxrb/elements/worksheet.rb +451 -226
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +16 -5
- data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +14 -9
- data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +296 -34
- data/lib/xlsxrb/ooxml/reader/listeners/style_listeners.rb +17 -3
- data/lib/xlsxrb/ooxml/reader.rb +52 -50
- data/lib/xlsxrb/ooxml/styles_parser.rb +36 -5
- data/lib/xlsxrb/ooxml/utils.rb +2 -2
- data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
- data/lib/xlsxrb/ooxml/workbook_writer.rb +242 -109
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +63 -31
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +119 -56
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +33 -13
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +75 -15
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +18 -8
- data/lib/xlsxrb/ooxml/writer.rb +124 -44
- data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
- data/lib/xlsxrb/ooxml/zip_generator.rb +2 -0
- data/lib/xlsxrb/ooxml/zip_reader.rb +112 -25
- data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
- data/lib/xlsxrb/stream_row.rb +56 -81
- data/lib/xlsxrb/stream_sheet.rb +542 -273
- data/lib/xlsxrb/stream_writer.rb +1536 -870
- data/lib/xlsxrb/style_builder.rb +667 -221
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +406 -143
- data/lib/xlsxrb/worksheet_builder.rb +1009 -900
- data/lib/xlsxrb.rb +1179 -1056
- data/sig/generated/xlsxrb/chart_builder.rbs +385 -159
- data/sig/generated/xlsxrb/dsl_helpers.rbs +81 -15
- data/sig/generated/xlsxrb/elements/cell.rbs +78 -70
- data/sig/generated/xlsxrb/elements/column.rbs +55 -3
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +35 -29
- data/sig/generated/xlsxrb/elements/image.rbs +7 -11
- data/sig/generated/xlsxrb/elements/metadata.rbs +1574 -0
- data/sig/generated/xlsxrb/elements/row.rbs +39 -42
- data/sig/generated/xlsxrb/elements/styles.rbs +66 -66
- data/sig/generated/xlsxrb/elements/types.rbs +27 -0
- data/sig/generated/xlsxrb/elements/workbook.rbs +46 -99
- data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -96
- data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +61 -4
- data/sig/generated/xlsxrb/ooxml/reader.rbs +2 -2
- data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
- data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +13 -1
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +6 -4
- data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +22 -13
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
- data/sig/generated/xlsxrb/ooxml/zip_generator.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +24 -9
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
- data/sig/generated/xlsxrb/stream_row.rbs +32 -33
- data/sig/generated/xlsxrb/stream_sheet.rbs +233 -181
- data/sig/generated/xlsxrb/stream_writer.rbs +961 -667
- data/sig/generated/xlsxrb/style_builder.rbs +402 -128
- data/sig/generated/xlsxrb/workbook_builder.rbs +223 -71
- data/sig/generated/xlsxrb/worksheet_builder.rbs +579 -453
- data/sig/generated/xlsxrb.rbs +205 -144
- data/sig/rexml.rbs +8 -0
- metadata +5 -5
- data/lib/xlsxrb/utils.rb +0 -291
- data/sig/generated/xlsxrb/utils.rbs +0 -184
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e4682f8228d5ffbe3681efdc627a082ac3b7c5b037d619b921c541e0c14b0fe
|
|
4
|
+
data.tar.gz: c8950a741c0ddfc4a0e7db66d514a9fb4a343ea5c9054b579891d2429289d6ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0964cde67e062b9704140855bf2bd5bf06a2ae8484c2dab7d9158afb2e6a8ab86afb6de9654aa7c75bb659478ecee492a340ec3a1ae0da7c5798de055091d695'
|
|
7
|
+
data.tar.gz: 77a3927cd829adf6a7481bb25965a95e3282f59a91bf688f6e10fb19cdaa0076586bb3a2e641b975f1b9a707e6dde39d510bd408fe2991175e4f2d26d0c05dc5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,259 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [0.2.0] - 2026-11-10
|
|
2
|
+
|
|
3
|
+
Upgrading from 0.1.x: see [docs/UPGRADING-0.2.md](docs/UPGRADING-0.2.md).
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Add `show_sheet_tabs?`, `full_calc_on_load?`, and `refresh_all?` boolean predicates on `Elements::WorkbookProperties`.
|
|
7
|
+
- Add `core_properties=` and `app_properties=` assignment setters on `WorkbookBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy`.
|
|
8
|
+
- Add `name` reader on `StreamWriter::WorksheetProxy` to mirror `WorksheetBuilder#name`.
|
|
9
|
+
- Value object delegators (`formula`, `array_formula`, `shared_formula`, `rich_text`, `hyperlink`, `comment`, `cell_error`) on `WorkbookBuilder`, and (`formula`, `array_formula`, `shared_formula`, `rich_text`, `cell_error`) on `WorksheetBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy`.
|
|
10
|
+
- Expose `:style_index` as a canonical `Data.define` member on `Elements::Row`.
|
|
11
|
+
- Add `columns` 0-argument reader on `WorksheetBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy` returning an array of `Elements::Column`, and on `TableBuilder` returning an array of `Elements::TableColumn`.
|
|
12
|
+
- Add `sheet_protection=` assignment setter on `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` accepting `Elements::SheetProtection`, `Hash`, `Boolean`, or `nil`.
|
|
13
|
+
- Add `print_titles=` assignment setter on `WorksheetBuilder`, `WorkbookBuilder`, `StreamWriter`, and `WorksheetProxy` accepting `Elements::PrintTitles`, `Hash`, or `nil`.
|
|
14
|
+
- Add value object members for data that the reader already parsed but the value objects dropped: `CoreProperties#language`, `WorkbookProperties#update_links`, `WorkbookProtection#revisions_algorithm_name`, `#revisions_hash_value`, `#revisions_salt_value`, and `#revisions_spin_count`, `PageSetup#page_order`, `#horizontal_dpi`, and `#vertical_dpi`, `TableColumn#data_cell_style`, `Font#vert_align`, `ThreadedComment#provider_id`, and `FilterColumn#blank` and `#custom_filters_and`.
|
|
15
|
+
- Add `Elements::FilterColumn.from_spec(column_id, spec)` and `FilterColumn#to_spec` to convert between filter column value objects and the `filter_column` hash format (`type: :filters`, `:custom`, `:dynamic`, `:top10`, `:color_filter`, or `:icon_filter`).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Unify property configuration methods across `WorksheetBuilder`, `WorkbookBuilder`, `StreamWriter`, and `WorksheetProxy` (`sheet_properties`, `sheet_view`, `sheet_format`, `print_options`, `workbook_properties`, `core_properties`, `app_properties`) to pure 0-argument getters returning value objects/hashes and keyword argument mutators returning `void` (`nil`).
|
|
19
|
+
- Unify single-value property accessors (`print_area`, `auto_filter`) across `WorksheetBuilder`, `StreamWriter`, `WorksheetProxy`, and `WorkbookBuilder` to 0-argument getters and dedicated `=` assignment setters.
|
|
20
|
+
- Unify boolean 0-argument getters to `?` predicate methods across builders: `TableBuilder` (`#show_row_stripes?`, `#show_column_stripes?`, `#show_first_column?`, `#show_last_column?`, `#totals_row?`, `#auto_filter?`), `DataValidationBuilder` (`#allow_blank?`, `#show_input_message?`, `#show_error_message?`), `ConditionalFormatBuilder` (`#bold?`, `#italic?`, `#stop_if_true?`, `#above_average?`, `#equal_average?`, `#percent?`, `#bottom?`), `ChartBuilder` (`#plot_visible_only?`, `#show_legend_key?`), `ChartBuilder::SeriesBuilder` (`#smooth?`), `WorksheetBuilder`/`StreamWriter`/`WorksheetProxy` (`#fit_to_page?`), and `WorkbookBuilder`/`StreamWriter` (`#show_sheet_tabs?`).
|
|
21
|
+
- Normalize structured metadata methods (`page_setup`, `page_margins`, `header_footer`, `sheet_protection`, `freeze_pane`, `split_pane`, `selection`, `sort_state`, `outline_properties`, `print_titles`) across `WorksheetBuilder`, `StreamWriter`, `WorksheetProxy`, and `WorkbookBuilder` to return their current immutable Value Object (or `nil`/Hash) when invoked with 0 arguments, and return `void` (`nil`) when called with configuration arguments.
|
|
22
|
+
- Change `TableBuilder#column` to return `void` (`nil`) instead of an internal column definition hash.
|
|
23
|
+
- Separate internal pipelines of `Xlsxrb.read` and `Xlsxrb.load`: `Xlsxrb.read` parses minimal streaming metadata directly yielding `StreamSheet` instances, while `Xlsxrb.load` materializes `Elements::Worksheet` directly without allocating intermediate `StreamSheet` instances or double-validating.
|
|
24
|
+
- Make `Elements::Cell` fully immutable by freezing instances upon instantiation in `Cell#initialize` and `Cell.fast_create`.
|
|
25
|
+
- Restrict `Elements::Workbook#sheets`, `#sheet`, `#[]`, `#each`, and `#active_sheet` signatures to `Elements::Worksheet` instances only.
|
|
26
|
+
- Rename `Elements::Styles#num_fmt` to `number_format_code`.
|
|
27
|
+
- Rename `Elements::Dxf` member and keyword `:num_fmt` to `:number_format`.
|
|
28
|
+
- Rename `Elements::SheetProperties` member and keyword `:page_setup_pr` to `:page_setup_properties`.
|
|
29
|
+
- Unify `StyleBuilder` single-attribute methods to dedicated 0-argument getters (`font_size`, `font_name`, `font_color`, `underline`, `vert_align`, `fill_color`, `align_horizontal`, `align_vertical`, `text_rotation`, `indent`, `number_format`) and assignment setters (`font_size=`, `font_name=`, etc.), and 0-argument boolean predicates (`bold?`, `italic?`, `strike?`, `underline?`, `wrap_text?`, `shrink_to_fit?`, `locked?`, `hidden?`, `superscript?`, `subscript?`) with assignment setters (`bold=`, `italic=`, etc.).
|
|
30
|
+
- Return frozen `Elements::IgnoredError` value objects from `WorksheetBuilder#ignored_errors`, `StreamWriter#ignored_errors`, and `StreamWriter::WorksheetProxy#ignored_errors`.
|
|
31
|
+
- Encapsulate internal methods by making `StyleBuilder#resolve_color` and `StreamSheet#auto_filter_data` private.
|
|
32
|
+
- Update blockless `Xlsxrb.read` to return an `Enumerator[StreamSheet, void]` with managed zip container lifecycle; use `Xlsxrb.load` for in-memory random access.
|
|
33
|
+
- Update `WorkbookBuilder#sheet` and `StreamWriter#sheet` parameter signatures with explicit keyword arguments `state: nil, tab_color: nil, code_name: nil`.
|
|
34
|
+
- Update `StyleBuilder#border` and `StyleBuilder#alignment` parameter signatures with explicit keyword arguments.
|
|
35
|
+
- Synchronize `RubyLsp::Xlsxrb::CompletionListener` completion items with the canonical v0.2.0 API.
|
|
36
|
+
- Unify `Xlsxrb.array_formula` signature to remove optional positional `ref` in favor of keyword `ref:`.
|
|
37
|
+
- Rename `Elements::FilterColumn` member `:col_id` to `:column_id`.
|
|
38
|
+
- Rename `Elements::WorkbookProperties` member `:active_tab` to `:active_sheet`, and rename `Elements::Workbook#active_tab` to `#active_sheet_index`.
|
|
39
|
+
- Unify `Elements::Worksheet` constructor parameter `sheet_calc_pr:` to `sheet_calc_properties:` and simplify `#with` to canonical keyword arguments.
|
|
40
|
+
- Change the default ZIP deflate level from zlib's default (6) to 1, exposed as `Xlsxrb::DEFAULT_COMPRESSION_LEVEL` and used when `compression_level` is omitted or `nil`. Writes are 17 to 43% faster and files 5 to 41% larger in the measurements of [ADR 0009](docs/adr/0009-default-zip-compression-level.md); pass `compression_level: 6` for the previous output.
|
|
41
|
+
- Raise `Xlsxrb::ParseError` when `Xlsxrb.read` or `Xlsxrb.load` opens a ZIP archive without a workbook part, such as an OpenDocument spreadsheet renamed to `.xlsx`. It was read as a workbook without sheets.
|
|
42
|
+
- Raise `Errno::ENOENT` (or `Errno::EISDIR`) when `Xlsxrb.read` or `Xlsxrb.load` gets a String that is neither XLSX or encrypted file content nor an existing file, instead of parsing the path itself as ZIP content and raising `ZipError: Invalid magic number`. Byte strings that are not an XLSX archive still raise `ZipError`.
|
|
43
|
+
- Raise `ArgumentError` for style options that `style` does not know (for example `bolt: true` or `size:` instead of `font_size:`), with a suggestion for the closest valid key, and for a nested group given together with its flat keys (`font: { size: 14 }, bold: true`). These options were silently ignored.
|
|
44
|
+
- Raise `ArgumentError` when a cell, row, or column refers to a style name that was never defined, with a suggestion for the closest defined name. Such cells were silently written unstyled. `:default` and `:none`, style indexes, and styles defined later in an `Xlsxrb.build` block are still accepted.
|
|
45
|
+
- Raise `ArgumentError` for keyword arguments that an `Elements` value object does not know, in `new` and `with`, including key names that 0.1.x accepted and ignored (for example `FreezePane.new(col: 1)`, `Font.new(sz: 11)`, or `Hyperlink.new(ref: "A1")`). Unknown keys were silently dropped, so a typo or an old name lost the value without an error. The message names the member to use for an old key name, or suggests the closest member for a typo. An old key name given together with its member (as in hashes read from files, which carry both) is dropped. `Chart`, `ConditionalFormat`, `ConditionalFormatRule`, `PivotTable`, `Shape`, `SortState`, `SparklineGroup`, and `Table` still collect other keys in their `options` member.
|
|
46
|
+
- Raise `ArgumentError` for border styles that are not border style names, with a suggestion for the closest one, for example `"slantedDashDot"` for `slantDashDot`. The style was written as given, which Excel does not accept.
|
|
47
|
+
- Lower the minimum required Ruby version from 4.0 to 3.4, and replace the Ruby 4.0-only `Array#rfind` in the drawing reader with `reverse_each.find`.
|
|
48
|
+
|
|
49
|
+
### Removed
|
|
50
|
+
- Remove dead private helper `Xlsxrb.write_workbook`.
|
|
51
|
+
- Remove legacy `unmapped_data` fallbacks for `:style_index` in `Elements::Row#initialize`, and `:style_index`, `:style`, `:best_fit`, and `:collapsed` in `Elements::Column#initialize`.
|
|
52
|
+
- Hide non-`?` boolean member reader methods on all 28 `Elements::MetadataRecord` `Data.define` classes and `Elements::Formula#calculate_always`.
|
|
53
|
+
- Remove singular property mutators (`sheet_property`, `workbook_property`, `core_property`, `app_property`) across builders in favor of unified `sheet_properties`, `workbook_properties`, `core_properties`, and `app_properties`.
|
|
54
|
+
- Remove dual getter/setter `value = OMITTED` parameter branches and non-`?` boolean getter methods (`bold`, `italic`, `strike`, `wrap_text`, `shrink_to_fit`, `locked`, `hidden`, `superscript`, `subscript`) from `StyleBuilder`.
|
|
55
|
+
- Remove `WorkbookBuilder#hyperlink` and `WorkbookBuilder#comment` delegators (use top-level `Xlsxrb.hyperlink` and `Xlsxrb.comment`).
|
|
56
|
+
- Remove legacy table key fallbacks (`:total_row_formula`, `:total_formula`, `:total_row`, `:total_row_count`) in `DslHelpers` and writers in favor of `:totals_row_formula`, `:totals_row`, and `:totals_row_count`.
|
|
57
|
+
- Remove legacy rule `:size` fallback in `DslHelpers.extract_dxf_from_rule!` (retaining `:font_size`).
|
|
58
|
+
- Remove legacy duplicate keys (`from_col`/`to_col`, `col:`, `col_fields:`, `dest_ref:`, `active_tab:`, `cols:`, `col_breaks:`, `si:`) across builders and writers in favor of canonical keys (`from_column`/`to_column`, `column:`, `column_fields:`, `destination:`, `active_sheet_index:`, `columns:`, `column_breaks:`, `shared_index:`).
|
|
59
|
+
- Remove in-memory `#close` on `Elements::Workbook` and `Elements::Worksheet`, and remove `#load` on `Elements::Worksheet` (`StreamSheet#close` and `StreamSheet#load` remain intact).
|
|
60
|
+
- Remove asymmetric legacy methods on `StreamSheet`: `#sheet_views`, `#first_column_index`, `#last_column_index`, `#legacy_drawing`, and `#ext_lst` in favor of `#sheet_view` and `#column_range`.
|
|
61
|
+
- Remove `Xlsxrb._read_workbook` and `Elements::Workbook#_load`.
|
|
62
|
+
- Remove deprecated alias `DslHelpers.sheet_name` in favor of `DslHelpers.sanitize_sheet_name`.
|
|
63
|
+
- Remove unused private cell serialization methods `build_raw_cell`, `build_row_attrs`, and `self.build_raw_cell_from_value` in `lib/xlsxrb.rb`.
|
|
64
|
+
- Remove empty `Xlsxrb::Utils` module and `lib/xlsxrb/utils.rb`.
|
|
65
|
+
- Remove positional offset arguments and `col_delta:` keyword from `Xlsxrb.expand_formula`, unifying the signature to `def self.expand_formula(formula, from_ref: nil, to_ref: nil, row_delta: nil, column_delta: nil)`.
|
|
66
|
+
- Remove singular `column:` and `row:` keyword arguments from `defined_name` across `WorkbookBuilder`, `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` (unified to `columns:` and `rows:`), and align `DslHelpers.normalize_defined_name_value`.
|
|
67
|
+
- Remove `show_symbols:` keyword argument from `outline_properties` across `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` (unified to `show_outline_symbols:`).
|
|
68
|
+
- Remove non-predicate boolean getters across builders: `TableBuilder` (`#show_row_stripes`, `#show_column_stripes`, `#show_first_column`, `#show_last_column`, `#totals_row`, `#auto_filter`), `DataValidationBuilder` (`#allow_blank`, `#show_input_message`, `#show_error_message`), `ConditionalFormatBuilder` (`#bold`, `#italic`, `#stop_if_true`, `#above_average`, `#equal_average`, `#percent`, `#bottom`), `ChartBuilder` (`#plot_visible_only`, `#show_legend_key`), `ChartBuilder::SeriesBuilder` (`#smooth`), `WorksheetBuilder`/`StreamWriter`/`WorksheetProxy` (`#fit_to_page`), `WorkbookBuilder`/`StreamWriter` (`#show_sheet_tabs`), and non-predicate `#escape_formulas` readers on `WorkbookBuilder`, `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` in favor of their `?` predicate equivalents.
|
|
69
|
+
- Remove workbook-level delegation methods and stream-lifecycle helpers (`active_sheet`, `active_sheet=`, `first_sheet`, `first_sheet=`, `show_sheet_tabs`, `show_sheet_tabs=`, `tab_ratio`, `tab_ratio=`, `workbook_property`, `workbook_protection`, `core_property`, `app_property`, `custom_property`, `properties`, `default_font`, `sheet_names`, `cleanup!`, `internal_sheet_setup`) from `StreamWriter::WorksheetProxy` to establish full method symmetry with `WorksheetBuilder`.
|
|
70
|
+
- Remove positional argument setters from `ChartBuilder` and `SeriesBuilder` in favor of pure 0-argument getters, dedicated `=` assignment setters, `title(**kwargs)`, keyword dictionary methods (`legend(**kwargs)`, `plot_area(**kwargs)`, etc.), and `series(**kwargs, &block)`.
|
|
71
|
+
- Remove `#[]`, `#[]=`, and `:in` fallback from `DataValidationBuilder` and `DslHelpers.normalize_data_validation`.
|
|
72
|
+
- Remove `#[]`, `#[]=`, `formulas`, `formulas=`, and fallbacks for `:size` and `:format_id` from `ConditionalFormatBuilder`.
|
|
73
|
+
- Remove `number_format_id` and `number_format_id=` from `StyleBuilder` in favor of `number_format` and `number_format=`.
|
|
74
|
+
- Remove duplicate and ambiguous keys in `StyleBuilder#font` (retaining `:name`, `:size`, `:color`, `:vert_align`) and top-level `StyleBuilder#apply_options!` (retaining `:font_name`, `:font_size`, `:font_color`, `:vert_align`, `:number_format`).
|
|
75
|
+
- Remove all remaining deprecated builder methods and aliases across `WorkbookBuilder`, `WorksheetBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy`:
|
|
76
|
+
- Removed `set_default_font`, `active_tab`, `active_tab=`, `protect_workbook`, `protect_sheet`, `validate_data`, `select_cell`, `page_break_row`, `page_break_col`, `add_row`, `skip_row`, `group_column`, `group_cols`, `group_col`, `group_row`, `outline_pr`, `add_sparkline`, `add_comment`, `add_threaded_comment`, `background_picture`, `background_picture=`, `picture`, `picture=`, `add_protected_range`, `add_cell_watch`, `ignore_error`, `add_ignored_error`, `sheet_calc_pr`, `sheet_calc_pr=`, `calc_pr`, `calc_pr=`, `phonetic_pr`, `phonetic_pr=`.
|
|
77
|
+
- Removed `ChartBuilder#secondary_axis`, `ChartBuilder#secondary_axis=`, and `SeriesBuilder#secondary_axis`.
|
|
78
|
+
- Removed deprecated methods on `StyleBuilder`: `size`, `size=`, `sz`, `sz=`, `num_fmt`, `num_fmt=`, `num_fmt_id`, `num_fmt_id=`.
|
|
79
|
+
- Removed deprecated methods on `TableBuilder`: `add_column`, `total_row`, `total_row=`, `total_row_count`, `total_row_count=`.
|
|
80
|
+
- Removed deprecated methods on `DataValidationBuilder`: `range`, `range=`, `col`, `col=`, `row`, `row=`, `in`, `in=`, `error`, `error=`, `prompt`, `prompt=`.
|
|
81
|
+
- Removed deprecated methods on `ConditionalFormatBuilder`: `range`, `range=`, `col`, `col=`, `row`, `row=`, `format_id`, `format_id=`, `size`, `size=`, `sz`, `sz=`.
|
|
82
|
+
- Removed dual getter/setter argument branches across builders (`active_sheet`, `first_sheet`, `show_sheet_tabs`, `tab_ratio`, `code_name`, `fit_to_page`, `tab_color`, `sheet_calc_properties`, `phonetic_properties`, `background_image`, `state`, `auto_filter`, `print_area`), strictly enforcing zero-argument getters and dedicated arity-1 assignment setters (`xxx=`).
|
|
83
|
+
- Removed deprecated keyword arguments: `styles:` and `style:` on `row` (use `cell_styles:` and `row_style:`); coordinate kwargs `row:`, `col_start:`, `col_end:`, `row_start:`, `row_end:` on `merge` (use `merge(range)`); `from_col:` and `to_col:` on `image` and `shape` (use `from_column:` and `to_column:`); `default_col_width:`, `base_col_width:`, and `outline_level_col:` on `sheet_format` (use `default_column_width:`, `base_column_width:`, `outline_level_column:`); `cols:` on `print_titles` (use `columns:`); `col:`, `ref_sheet:`, and `local:` on `defined_name` (use `column:` and `scope:`); `col:` and `except_col:` on `data_validation`, `conditional_format`, and `ignored_error` (use `columns:` and `except_columns:`); `si:` on `Formula` (use `shared_index:`).
|
|
84
|
+
- Remove `StreamWriter#shared_strings` reader method in favor of `shared_strings?`.
|
|
85
|
+
- Remove constant `Xlsxrb::MAX_COL` in favor of `Xlsxrb::MAX_COLUMN`.
|
|
86
|
+
- Remove `Xlsxrb::Error::DIV0`..`VALUE` cell error constants on the exception class in favor of `Elements::CellError::*`.
|
|
87
|
+
- Remove `Elements::RichTextRun#sz` in favor of `font_size`.
|
|
88
|
+
- Replace the `top_row` and `left_column` members of `Elements::FreezePane` and `Elements::SplitPane` with `top_left_cell`. Neither member was read or written.
|
|
89
|
+
- Remove the `escape_formulas:` option of `Xlsxrb.write`, `Xlsxrb.build`, `StreamWriter`, `WorkbookBuilder`, and `WorksheetBuilder`, with its `escape_formulas?` and `escape_formulas=` accessors. It was passed down to the worksheet writer but never used: output was identical with and without it. Strings are always written as text cells, which Excel does not evaluate as formulas, with or without the option.
|
|
90
|
+
- Remove deprecated `Xlsxrb.modify`, `Elements::Workbook#update_sheet`, and `Elements::Worksheet#update_cell` in favor of streaming transformations (`Xlsxrb.read` + `Xlsxrb.write`) or template generation via `Xlsxrb.write`.
|
|
91
|
+
- Remove Hash-like access (`#[]`, `#key?`, `#dig`, `#fetch`, `#merge`, and `== Hash`) on `Elements::MetadataRecord` value objects and `Elements::Hyperlink#[]` in favor of direct reader method calls and `#to_h`.
|
|
92
|
+
- Remove deprecated methods on `Elements::Row`: `pad_empty_cells` (use `padded`), `cells_hash` (use `cells`), `formulas` (use `formula_expressions`), and bare boolean queries (`hidden`, `custom_height`, `collapsed` in favor of `?`-suffixed predicates).
|
|
93
|
+
- Remove deprecated methods on `StreamRow`: `to_h` (use `values` or `cells`), `formulas` (use `formula_expressions`), and bare boolean queries (`hidden`, `custom_height`, `collapsed` in favor of `?`-suffixed predicates).
|
|
94
|
+
- Remove deprecated methods on `Elements::Cell`: `content` (use `value`), `column_index`, `column_letter`, `parse_ref`, `date1904` (use `date1904?`), `link?` (use `hyperlink?`), and `threaded_comments?` (use `threaded_comment?`).
|
|
95
|
+
- Remove keyword argument `date1904:` on `Cell#to_date` and `Cell#to_time`.
|
|
96
|
+
- Remove deprecated `StreamSheet#cell` and `Elements::Worksheet#cell` in favor of coordinate bracket access (`sheet[...]`).
|
|
97
|
+
- Remove deprecated `StreamSheet#first_row` and `StreamSheet#last_row` in favor of `row_range` or `dimension_bounds`.
|
|
98
|
+
- Remove deprecated `CoordinateAccess#cells_hash`, `first_column`, `first_col`, `last_column`, `last_col`, and `cell_value`.
|
|
99
|
+
- Remove deprecated `Elements::Image#cell` and `cell_ref` (use `ref`), `from_col` (use `from_column`), and `to_col` (use `to_column`).
|
|
100
|
+
- Remove remaining deprecated aliases, duplicate Data members, and initialization fallbacks across `Elements::*` Value Objects:
|
|
101
|
+
- Remove duplicate `Data.define` members: `:cols` from `Elements::PrintTitles` (use `:columns`), `:col` from `Elements::FreezePane` (use `:column`), `:first_tab` from `Elements::WorkbookProperties` (use `:first_sheet`), `:outline_pr` from `Elements::SheetProperties` (use `:outline_properties`), `:rel_id`, `:ext`, and `:filename` from `Elements::BackgroundImage` (use `:r_id`, `:extension`, `:path`), and `:location` from `Elements::PivotTable` (use `:ref`).
|
|
102
|
+
- Remove `Elements::RichTextRun#[]` and `other.is_a?(Hash)` branches from `Elements::Hyperlink#==`, `Elements::CustomProperty#==`, and `Elements::Styles#==`.
|
|
103
|
+
- Remove non-predicate formula aliases on `Elements::Formula`: `always_calculate_array`, `assign_to_name`, `data_table_2d`, and `data_table_row` in favor of predicate methods (`?`).
|
|
104
|
+
- Remove `Elements::Column#letter` in favor of canonical `column_letter`.
|
|
105
|
+
- Remove `Elements::Styles#format_code` in favor of `number_format`.
|
|
106
|
+
- Remove `StreamSheet#_load` in favor of `StreamSheet#load`.
|
|
107
|
+
- Remove deprecated `conditional_formatting:` and `col_breaks:` keyword arguments in `Elements::Worksheet#initialize` in favor of `conditional_formats:` and `column_breaks:`.
|
|
108
|
+
- Remove legacy keyword arguments and aliases on element Value Objects: `SheetFormat` (`default_col_width`, `outline_level_col`, `base_col_width`), `FilterColumn` (`hidden_button:`), `PageBreak` (`manual:`), `Comment` (`cell:` and `alias cell ref`), `ThreadedComment` (`cell:`, `person_id:`, `dt:`, `timestamp:`, `done:`, and `alias done resolved`), `DataValidation` (`show_dropdown` and `show_dropdown?`), `ConditionalFormatRule` (`format_id` and `alias formulas formula`), `TableColumn` (`data_formula:` and `alias data_formula calculated_column_formula`), `Sparkline` (`location_ref`, `location`, `data_ref`, `f`, `data`), `SparklineGroup` (`display_empty`, `max`, `min`), `Chart` (`rid`, `chart_type`, `from_col`, `to_col`), `HeaderFooterImage` (`rid`, `ext`, `filename`), `Font` (`sz`), `Fill` (`pattern`), and `CellXf` (`number_format_id`).
|
|
109
|
+
- Remove deprecated `Elements::Worksheet#dimension=` (use `with(dimension: ...)`), `Elements::Worksheet#with_images`, and `StreamSheet#with_images`.
|
|
110
|
+
- Remove deprecated `Elements::Worksheet#conditional_formatting` and `StreamSheet#conditional_formatting` in favor of `conditional_formats`.
|
|
111
|
+
- Remove deprecated `Elements::Styles#add_xf`, `add_num_fmt`, and `num_fmts` in favor of `add_cell_xf`, `add_number_format`, and `number_formats`.
|
|
112
|
+
- Remove deprecated `Elements::Styles#xf`, `num_fmt`, `format_code_for`, `classification_for`, and `sz`.
|
|
113
|
+
- Remove deprecated `Xlsxrb::Utils` coordinate and date conversion methods (`col_name_to_index`, `col_index_to_name`, `ref_to_row_col`, `row_col_to_ref`, `parse_range`, `range_to_ref`, `date_to_serial`, `serial_to_date`, `serial_to_time`, `time_to_serial`, `split_coordinate`, `valid_excel_date?`, `expand_formula`, `datetime_to_serial`) in favor of canonical `Xlsxrb.*` entry points.
|
|
114
|
+
- Remove deprecated transitional top-level aliases on `Xlsxrb`: `datetime_to_serial`, `serial_to_datetime`, `color_to_hex`, `sheet_name`, `stream`, and `format` (use `Xlsxrb.format_value`).
|
|
115
|
+
- Remove deprecated transitional aliases `to_workbook` on `Workbook`, `to_worksheet` on `Worksheet` and `StreamSheet`, `each_sheet` on `Workbook`, and `col_breaks` on `Worksheet` and `StreamSheet`.
|
|
116
|
+
- Remove non-predicate boolean queries on element readers (`trim_empty_rows`, `pad_empty_rows`, `pad_empty_cells`, `fit_to_page`, `show_sheet_tabs`, `full_calc_on_load`) in favor of `?`-suffixed methods (`trim_empty_rows?`, `pad_empty_rows?`, `pad_empty_cells?`, `fit_to_page?`, `show_sheet_tabs?`, `full_calc_on_load?`).
|
|
117
|
+
|
|
118
|
+
### Fixed
|
|
119
|
+
- Write the pattern type of cell fills in `Xlsxrb.build` and in `Xlsxrb.write` of loaded workbooks. The styles writer read `:pattern` while `Elements::Fill` names it `:pattern_type`, so every fill was written with `patternType="none"` and cell fill colors did not show.
|
|
120
|
+
- Protect the workbook with `workbook_protection(password:)`. `Elements::WorkbookProtection` had no `password` member, so the password was dropped and the workbook was written without one. A plain-text password is now hashed with SHA-512, as for `sheet_protection`, and a 4-digit hexadecimal value is written as the legacy `workbookPassword`. `Xlsxrb.load` also keeps the hash, revision lock, and revisions password attributes of `<workbookProtection>`, which it dropped, so that `Xlsxrb.write` writes them back.
|
|
121
|
+
- Keep filter column conditions in `Elements::Worksheet#filter_columns` and `StreamSheet#filter_columns`. Hashes in the `filter_column` format (`type:`, `values:`, `operator:`, ...) were passed to `Elements::FilterColumn.new`, which dropped those keys, so the readers returned empty filter columns and `Xlsxrb.write` of value objects wrote an `<autoFilter>` without its conditions.
|
|
122
|
+
- Write threaded comments built from `Elements::ThreadedComment` with their `created_at` time and `resolved` state; the writer only looked at the `dt`/`timestamp` and `done` keys.
|
|
123
|
+
- Write the `horizontalDpi` and `verticalDpi` attributes of page setup when they are positive; the schema requires at least 1.
|
|
124
|
+
- Keep the pattern type of differential format fills loaded from `styles.xml` (`Elements::Dxf#fill`). The styles reader names it `pattern:`, which `Elements::Fill` dropped.
|
|
125
|
+
- Wrap keyword arguments with double splat in Data.define constructors across Elements to prevent heap corruption and segfaults in CRuby 4.0 Ractors.
|
|
126
|
+
- Keep the top-left cell of freeze and split panes. `freeze_pane(top_left_cell:)` and the reader both used a `top_left_cell` that `Elements::FreezePane` and `Elements::SplitPane` did not have, so the value objects dropped it and the writer always wrote the cell just past the frozen rows and columns; the reader also did not read `topLeftCell` for frozen panes.
|
|
127
|
+
- Keep the time of day of `DateTime` values. `Xlsxrb.date_to_serial`, `Xlsxrb.time_to_serial`, and cell values written by `Xlsxrb.write` and `Xlsxrb.build` treated `DateTime` (a subclass of `Date`) as a date, dropping the time and applying the date-only format. They now handle it like `Time`.
|
|
128
|
+
- Write worksheets whose `selection` is an Array, one selection per pane, as `Elements::Worksheet` accepts. `Xlsxrb.write` called `to_h` on the Array and raised `TypeError`.
|
|
129
|
+
- Link each sheet that `Xlsxrb.write` streams from a block to its own drawing, comments, threaded comments, tables, and pivot tables. Part numbers restarted at 1 for every sheet, so the relationships of later sheets pointed to the parts of the first sheet that had them, and the second sheet showed the first sheet's images, comments, and tables.
|
|
130
|
+
- Write each image of a sheet to its own media file. Every image in a drawing was written as `xl/media/imageN.png` with the drawing's number, so a sheet with two or more images produced duplicate ZIP entries and one picture for all of them.
|
|
131
|
+
- Read the name, location, and cache ID of pivot tables saved by Excel 2010 and later. The `x14:pivotTableDefinition` that such files keep in `extLst` replaced the pivot table the reader had collected.
|
|
132
|
+
- Resolve pivot table fields given by name, such as `row_fields: ["Region"]`, through `field_names:`, and accept `field:` (a name or an index) in data fields. Names were written as is, as in `<field x="Region"/>` and `fld=""`, which is invalid. A name without `field_names:`, or one missing from it, raises `ArgumentError`.
|
|
133
|
+
- Write workbooks loaded with pivot tables. Loaded pivot tables carry their source, field names, and shared items in `cache`, but the writer looked for the builder's `source_ref` and `field_names`, so `Xlsxrb.write` raised `NoMethodError`; a pivot table on a sheet named `Sheet1` also raised `ArgumentError: sheet already exists`. Loaded pivot tables are now written from their cache definition, including sources that name a table, with typed shared items (`<n>`, `<b>`, `<m>`). As for pivot tables built with `pivot_table`, the cache is written with `refreshOnLoad`, so Excel rebuilds it from the source data; the item order and other layout details of the original pivot table are not kept.
|
|
134
|
+
- Write the `sz` element of differential format fonts before `color` and `name`, in the order of `CT_Font`.
|
|
135
|
+
- Keep the cell style formats (`cellStyleXfs`) and named cell styles (`cellStyles`, such as Normal and Heading 1) of loaded workbooks. The writer always wrote one default style format and no named styles, so cell formats that referred to other style formats pointed to missing entries.
|
|
136
|
+
- Keep the chart type of loaded charts. The reader returns the chart element name (`"lineChart"`), which the writer did not recognize, so every loaded chart was written as a bar chart.
|
|
137
|
+
- Raise `ArgumentError` when `Xlsxrb.write` gets an `Elements::Workbook` without sheets, as `Xlsxrb.build` and `StreamWriter` do, instead of writing a workbook with an empty `<sheets>` element, which is invalid.
|
|
138
|
+
- Keep the built-in unit of chart display units (`val_axis_disp_units`) whose label has a fill, line, or number format. Reading the label replaced the unit with a hash that had only the label.
|
|
139
|
+
- Write the children of chart series in schema order: `spPr` first, then `invertIfNegative`, `marker`, or `explosion`, then `dPt`. Series with a fill or line together with one of the others, or with data points, were invalid.
|
|
140
|
+
- Give pivot table row and column fields without `items:` an `<items>` list with the default subtotal item. Excel for Mac crashed when it opened a pivot table whose axis fields had no items.
|
|
141
|
+
- Keep the table style of loaded tables. The reader returns the style as a hash, which `Elements::Worksheet` wrapped as the style name, so `Xlsxrb.write` wrote `<tableStyleInfo name="{name: ...}">` and Excel repaired the table; `StreamSheet#tables` dropped the style.
|
|
142
|
+
- Write pivot fields with `defaultSubtotal="0"` without the default subtotal item, and keep the `firstHeaderRow`, `firstDataRow`, and `firstDataCol` of a loaded pivot table's location instead of writing 1 for each. Excel repaired loaded pivot tables whose fields turned off the default subtotal. Loaded pivot tables are written without page field counts, since their page fields are not written.
|
|
143
|
+
- Leave sheets unprotected when their `<sheetProtection>` element has no `sheet` attribute, which defaults to false. The reader left `sheet` unset and the writer treated that as protected, so `Xlsxrb.write` of a loaded workbook protected such sheets.
|
|
144
|
+
- Keep the `family` and `scheme` of fonts loaded from `styles.xml`.
|
|
145
|
+
- Keep comments that are shown permanently instead of on hover. The VML drawing always hid them and the reader did not read `<x:Visible/>`; `comment` on `WorksheetBuilder` and `StreamWriter` now take `visible:`, and `Elements::Comment#visible?` is read from and written to the VML drawing.
|
|
146
|
+
- Keep the position and size of comment boxes. The VML writer placed every box next to its cell and the reader did not read `<x:Anchor>`, so loaded comments that were shown permanently moved and could overlap. `Elements::Comment#anchor` holds the eight `<x:Anchor>` integers; `nil` keeps the default box next to the cell.
|
|
147
|
+
- Decode entity references such as `&` and `"` in attribute values read from files, including number format codes, hyperlink display texts, tooltips, and locations, and table column names. REXML's SAX2 parser passes attribute values as written, so a loaded format such as `"$"#,##0` read back as `"$"#,##0` and `Xlsxrb.write` wrote it as `&quot;$&quot;#,##0`, changing the format.
|
|
148
|
+
- Keep gradient fills. `Elements::Fill` had no member for a `<gradientFill>`, so `Xlsxrb.load` dropped the gradients of a workbook and wrote such fills as empty pattern fills, and `Xlsxrb.build` with `fill_gradient` raised `ArgumentError`. `Elements::Fill#gradient` holds the gradient type, degree, sides, and stops.
|
|
149
|
+
- Write `firstSliceAng` and `holeSize` in doughnut charts, 0 and 50 unless given; doughnut charts without them did not validate.
|
|
150
|
+
- Write sheet tab colors given by name, such as `tab_color: :red`, as aRGB hex. The name was written as `rgb="red"`, which is not a valid color. An unknown name raises `ArgumentError`.
|
|
151
|
+
- Write workbooks loaded from files with rich-text comments, such as comments that Excel starts with the author's name in bold. `MetadataRecord#to_h` called `Enumerable#to_h` on the `Elements::RichText` text of `Elements::Comment`, so `Xlsxrb.write` raised `TypeError`. `to_h` now keeps `RichText` values as they are.
|
|
152
|
+
- Write workbooks loaded from files whose `docProps/app.xml` lists `HeadingPairs`, as files saved by Excel do. `MetadataRecord#to_h` called `to_h` on the `[name, count]` pairs of `AppProperties#heading_pairs`, so `Xlsxrb.write` raised `TypeError`.
|
|
153
|
+
- Keep the date or time number format on `Date` and `Time` cell values that are given a cell style without a `number_format` (for example `cell_styles: [:bold]`). The style replaced the automatic `yyyy-mm-dd` format, so Excel showed the serial number. Such cells now get a variant of their style that adds the default format, in both `Xlsxrb.write` blocks and `Xlsxrb.build`.
|
|
154
|
+
- Inherit `sheet_format` `default_column_width` as the width of columns that define `style:` without `width:`. The column writer still looked up the removed `default_col_width` key and dropped the width.
|
|
155
|
+
- Raise `ArgumentError` when `rows:` or `columns:` on `data_validation` and `conditional_format` reach outside the Excel grid (for example `rows: 1..Xlsxrb::MAX_ROW`, which is one past the last 0-based row) instead of writing an invalid reference such as `A2:A1048577`.
|
|
156
|
+
- Keep the REXML entity expansion limits that the application set before `require "xlsxrb"`. Loading xlsxrb reset `REXML::Security.entity_expansion_limit` and `entity_expansion_text_limit` to the REXML defaults, which undid hardening such as an application setting the limit to 0 to disable entity expansion.
|
|
157
|
+
- Keep reading entries after one that ends with a data descriptor when `ZipReader` falls back to walking local headers (an archive without a readable central directory). Ruby's `Zlib::Inflate` drops input past the end of the deflate stream, so the reader skipped over the following entries; it now rewinds by the compressed length, and reads 8-byte sizes from the data descriptor of ZIP64 entries.
|
|
158
|
+
- Build cells in streaming and in-memory reads with one direct initializer instead of an `instance_variable_set` call per attribute, which had grown from 7 to 14 calls per cell since 0.1.10. A 1,000,000-cell streaming read is about 12% faster.
|
|
159
|
+
- Take the `r`, `s`, and `t` cell attributes from the cell scanning regex when they appear in that order, as Excel and xlsxrb write them, instead of three more regex lookups per cell (other orders still fall back to those lookups), and stop copying cell values that need no whitespace stripping or re-encoding. A 1,000,000-cell streaming read is about 16% faster and allocates 43% fewer objects.
|
|
160
|
+
- Check cell reference digits with plain byte comparisons instead of `Comparable#between?`, and yield cells instead of calling a block Proc, in the cell scanning loops (about 3% faster streaming reads).
|
|
161
|
+
- Consume inflated ZIP entry data by offset instead of `slice!`, which moved the rest of each inflated chunk on every read, and stop re-encoding chunks that are already binary. Streaming reads run half as many garbage collections.
|
|
162
|
+
- Write ZIP64 records when an entry size, a file offset, or the entry count exceeds the 32-bit (16-bit for counts) ZIP fields. Sizes were truncated to 32 bits, so a worksheet whose XML exceeded 4 GiB uncompressed produced a corrupt XLSX without an error. Archives below these limits are written unchanged, except that entries streamed to unseekable output are declared ZIP64 up front, because their size is unknown when the local header is written. `ZipReader` also reads the ZIP64 end of central directory record. See [ADR 0008](docs/adr/0008-zip64-only-when-a-limit-is-exceeded.md).
|
|
163
|
+
|
|
164
|
+
## [0.1.18] - 2026-11-07
|
|
165
|
+
|
|
166
|
+
### Added
|
|
167
|
+
- Add Value Object factory delegator methods (`formula`, `array_formula`, `shared_formula`, `rich_text`, `comment`, `cell_error`, `hyperlink`) across `WorkbookBuilder`, `WorksheetBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy`.
|
|
168
|
+
- Add canonical coordinate conversion facade methods `Xlsxrb.parse_ref`, `Xlsxrb.cell_to_ref`, `Xlsxrb.column_index`, and `Xlsxrb.column_letter`.
|
|
169
|
+
- Add `Xlsxrb.format_value` as the canonical value formatting method.
|
|
170
|
+
- Add `Xlsxrb.time_to_serial` (and `Utils.time_to_serial`) for converting Time/Date objects to Excel numeric serial numbers.
|
|
171
|
+
- Add `Xlsxrb::MAX_COLUMN` constant (16,384) representing the maximum column count supported by Excel / OpenXML.
|
|
172
|
+
- Support passing nested bounding coordinate arrays `[[top_row, left_col], [bottom_row, right_col]]` (as returned by `parse_range`) to `Xlsxrb.range_to_ref`.
|
|
173
|
+
- Support `column_delta:` keyword in `Xlsxrb::Utils.expand_formula`.
|
|
174
|
+
- Support `ref:` keyword argument in `Xlsxrb.array_formula` and include `Elements::CellError` in `cached_value:` types.
|
|
175
|
+
- Support `new_password:` and writer/reader option forwarding in `Xlsxrb.modify`, and return the block result.
|
|
176
|
+
- Define Ractor-shareable frozen `Elements::CellError` constants (`DIV0`, `NA`, `NAME`, `NULL`, `NUM`, `REF`, `VALUE`, `GETTING_DATA`) on `Elements::CellError`.
|
|
177
|
+
- Add canonical cell-level and row-level style keywords `cell_styles:` and `row_style:` across `WorksheetBuilder#row`, `StreamWriter#row`, and `StreamWriter::WorksheetProxy#row`.
|
|
178
|
+
- Expose `:style_index` as a canonical `Data.define` member on `Elements::Row`.
|
|
179
|
+
- Add `style:` keyword to `Elements::Cell.new` and `Elements::Worksheet#update_cell` for style names and inline style definitions.
|
|
180
|
+
- Add 1-based `row_range` and `column_range` boundaries to `Elements::Worksheet` (via `CoordinateAccess`) and `StreamSheet` (from sheet dimension bounds), returning idiomatic `Range[Integer]` boundaries.
|
|
181
|
+
- Support 2D coordinate indexing `sheet[row, col]` and letter column indexing `sheet[row, "A"]` on `Elements::Worksheet` and `CoordinateAccess`.
|
|
182
|
+
- Add `column` and `columns` builder methods across `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` with unified options.
|
|
183
|
+
- Support 0-based page break indices (`row_breaks`, `column_breaks`) across builders and readers.
|
|
184
|
+
- Add `Elements::WorkbookProperties#active_sheet` and `Elements::Workbook#active_sheet_index`.
|
|
185
|
+
- Add `Elements::FilterColumn#column_id`.
|
|
186
|
+
- Add structured Hash access for `category_axis` and `value_axis` titles on `Elements::Chart`.
|
|
187
|
+
- Add dedicated assignment setters returning assigned value (`active_sheet=`, `first_sheet=`, `show_sheet_tabs=`, `tab_ratio=`, `code_name=`, `fit_to_page=`, `tab_color=`, `phonetic_properties=`, `sheet_calc_properties=`, `background_image=`, `totals_row=`, `totals_row_count=`, `state=`, `print_area=`, `print_titles=`) across `WorkbookBuilder`, `WorksheetBuilder`, `StreamWriter`, and `StreamWriter::WorksheetProxy`.
|
|
188
|
+
- Add zero-argument property getters across builders and `StyleBuilder`.
|
|
189
|
+
- Add predicate methods (`bold?`, `italic?`, `strike?`, `wrap_text?`, `shrink_to_fit?`, `locked?`, `hidden?`, `superscript?`, `subscript?`) and assignment setters (`font=`, `fill=`, `border=`, `vert_align=`, `superscript=`, `subscript=`, `wrap_text=`, `shrink_to_fit=`, `locked=`, `hidden=`, `protection=`, `number_format=`) on `StyleBuilder`.
|
|
190
|
+
- Re-affirm `totals_row`, `totals_row=`, `totals_row_count`, and `totals_row_count=` as canonical on `TableBuilder` to align with ECMA-376 `totalsRowCount`.
|
|
191
|
+
- Promote reader metadata to immutable Data value objects across `Elements::Styles`, `Elements::Workbook`, and `Elements::Cell`.
|
|
192
|
+
- Add `Elements::Styles#number_format_code(id)`.
|
|
193
|
+
- Support Symbol sheet lookup in `Elements::Workbook#sheet` and `Elements::Workbook#[]`.
|
|
194
|
+
- Freeze `Elements::Cell` instances on instantiation (`initialize` and `fast_create`).
|
|
195
|
+
- Return frozen `Array[Elements::IgnoredError]` from `WorksheetBuilder#ignored_errors`, `StreamWriter#ignored_errors`, and `WorksheetProxy#ignored_errors`.
|
|
196
|
+
- Add XML element existence guards for `merged_cells`, `data_validations`, `conditional_formats` on `StreamSheet`.
|
|
197
|
+
- Establish four-pillar I/O architecture: `Xlsxrb.read`, `Xlsxrb.write`, `Xlsxrb.load`, and `Xlsxrb.build`.
|
|
198
|
+
- Direct worksheet materialization in `Xlsxrb.load` without intermediate `StreamSheet` allocations.
|
|
199
|
+
- Support on-demand zip reopen after close in `Ooxml::ZipReader`.
|
|
200
|
+
- Clarify `@api private` on `Ooxml::Reader`, `Ooxml::Writer`, and `Ooxml::ZipGenerator`.
|
|
201
|
+
|
|
202
|
+
### Changed
|
|
203
|
+
- Update `Elements::Row#[]` and `StreamRow#[]` to resolve column indices and column letters via `cell_at` instead of indexing the raw sparse `cells` array, returning `nil` when a cell at the specified column is absent.
|
|
204
|
+
- Separate builder getter (`xxx`) and setter (`xxx=`) methods, allowing explicit `nil` resets.
|
|
205
|
+
- Encapsulate `StyleBuilder#resolve_color` as `private`.
|
|
206
|
+
- Encapsulate `StreamSheet#auto_filter_data` as `private`.
|
|
207
|
+
- Make `Xlsxrb._read_workbook` `private_class_method`.
|
|
208
|
+
|
|
209
|
+
### Deprecated
|
|
210
|
+
- `DslHelpers.sheet_name` is deprecated in favor of `DslHelpers.sanitize_sheet_name`; will be removed in version 0.2.0.
|
|
211
|
+
- Positional `pos_ref` in `Xlsxrb.array_formula` is deprecated in favor of keyword `ref:`; will be removed in version 0.2.0.
|
|
212
|
+
- Top-level aliases `Xlsxrb.stream`, `Xlsxrb.sheet_name`, `Xlsxrb.color_to_hex`, `Xlsxrb.serial_to_datetime`, and `Xlsxrb::Utils.serial_to_datetime` are deprecated in favor of `Xlsxrb.read`, `Xlsxrb.sanitize_sheet_name`, `Xlsxrb.to_hex_color`, and `Xlsxrb.serial_to_time`; will be removed in version 0.2.0.
|
|
213
|
+
- `Xlsxrb.format` is deprecated in favor of `Xlsxrb.format_value`; will be removed in version 0.2.0.
|
|
214
|
+
- `Xlsxrb.datetime_to_serial` and `Xlsxrb::Utils.datetime_to_serial` are deprecated in favor of `Xlsxrb.time_to_serial`; will be removed in version 0.2.0.
|
|
215
|
+
- `Xlsxrb::MAX_COL` is deprecated in favor of `Xlsxrb::MAX_COLUMN`; will be removed in version 0.2.0.
|
|
216
|
+
- `Xlsxrb::Utils` coordinate and date conversion methods (`col_name_to_index`, `col_index_to_name`, `ref_to_row_col`, `row_col_to_ref`, `parse_range`, `range_to_ref`, `date_to_serial`, `serial_to_date`, `serial_to_time`, `time_to_serial`) and `Elements::Cell.column_index`, `column_letter`, `parse_ref` are deprecated in favor of top-level `Xlsxrb.*` helpers; will be removed in version 0.2.0.
|
|
217
|
+
- Keyword `:col_delta` in `Xlsxrb::Utils.expand_formula` is deprecated in favor of `:column_delta`; will be removed in version 0.2.0.
|
|
218
|
+
- Keyword `:si` in `Xlsxrb.shared_formula` is deprecated in favor of `:shared_index`; will be removed in version 0.2.0.
|
|
219
|
+
- `Xlsxrb::Error::DIV0`..`VALUE` cell error constants on the exception class are deprecated in favor of `Elements::CellError::DIV0`..`VALUE`; will be removed in version 0.2.0.
|
|
220
|
+
- Redundant method and setter aliases across builders and element readers (`add_row`, `skip_row`, `group_column`, `group_cols`, `group_col`, `group_row`, `outline_pr`, `add_threaded_comment`, `background_picture`, `picture`, `background_picture=`, `picture=`, `add_protected_range`, `add_cell_watch`, `phonetic_pr`, `phonetic_pr=`, `set_default_font`, `add_column`, `first_col`, `last_col`, `range`, `range=`, `col`, `col=`, `row`, `row=`, `sz`, `sz=`, `error`, `error=`, `prompt`, `prompt=`) are deprecated and will be removed in version 0.2.0.
|
|
221
|
+
- Singular `column:` and `row:` keywords in `defined_name` are deprecated in favor of plural `columns:` and `rows:`; will be removed in version 0.2.0.
|
|
222
|
+
- `show_symbols:` keyword in `outline_properties` is deprecated in favor of `show_outline_symbols:`; will be removed in version 0.2.0.
|
|
223
|
+
- `fit_to_page?` on builders is deprecated in favor of `fit_to_page`; will be removed in version 0.2.0.
|
|
224
|
+
- Keywords `styles:` and `style:` on `WorksheetBuilder#row`, `StreamWriter#row`, and `WorksheetProxy#row` are deprecated in favor of `cell_styles:` and `row_style:`; will be removed in version 0.2.0.
|
|
225
|
+
- Passing non-Integer style names or Hash definitions to `style_index:` on `Elements::Cell.new` and `Elements::Worksheet#update_cell` is deprecated in favor of `style:`; will be removed in version 0.2.0.
|
|
226
|
+
- `Elements::Worksheet#cell` is deprecated in favor of bracket access (`sheet["A1"]` or `sheet[row, col]`) and will be removed in version 0.2.0.
|
|
227
|
+
- `StreamSheet#cell` is deprecated in favor of materializing an `Elements::Worksheet` via `sheet.load` and using coordinate bracket access; will be removed in version 0.2.0.
|
|
228
|
+
- `StreamSheet#first_row` and `StreamSheet#last_row` returning integer row numbers are deprecated in favor of `row_range` or `dimension_bounds`; will be removed in version 0.2.0.
|
|
229
|
+
- Passing coordinate keyword arguments (`row:`, `col_start:`, `col_end:`, `row_start:`, `row_end:`) to `merge` on `WorksheetBuilder`, `StreamWriter`, and `WorksheetProxy` is deprecated in favor of coordinate range strings (e.g. `"A1:C1"`); coordinate kwargs will be removed in version 0.2.0.
|
|
230
|
+
- `Elements::FilterColumn#col_id` is deprecated in favor of `#column_id`; will be removed in version 0.2.0.
|
|
231
|
+
- `Elements::WorkbookProperties#active_tab` is deprecated in favor of `#active_sheet`, and `Elements::Workbook#active_tab` is deprecated in favor of `#active_sheet_index`; will be removed in version 0.2.0.
|
|
232
|
+
- `Elements::Chart#cat_axis_title` and `#val_axis_title` are deprecated in favor of `category_axis[:title]` and `value_axis[:title]`; will be removed in version 0.2.0.
|
|
233
|
+
- `Elements::Worksheet` constructor keywords `sheet_calc_pr:`, `calc_pr:`, `phonetic_pr:`, `background_picture:`, `picture:` are deprecated in favor of canonical keyword arguments; will be removed in version 0.2.0.
|
|
234
|
+
- Calling builder getter methods with arguments to set values or mutate state (`active_sheet`, `first_sheet`, `show_sheet_tabs`, `tab_ratio`, `code_name`, `tab_color`, `sheet_calc_properties`, `phonetic_properties`, `background_image`, `state`, and subbuilders `TableBuilder`, `DataValidationBuilder`, `ConditionalFormatBuilder`) is deprecated and will become 0-argument getters in version 0.2.0; use dedicated setters (`xxx=`) instead.
|
|
235
|
+
- Calling `fit_to_page` with arguments is deprecated and will become a 0-argument boolean getter in version 0.2.0; use `fit_to_page = true/false` or `page_setup(fit_to_width: ..., fit_to_height: ...)` instead.
|
|
236
|
+
- Calling `StyleBuilder` boolean mutator methods (`bold`, `italic`, `underline`, `strike`, `superscript`, `subscript`, `wrap_text`, `shrink_to_fit`, `locked`, `hidden`) with zero arguments to mutate state is deprecated; pass `true` explicitly (e.g. `bold(true)`).
|
|
237
|
+
- `TableBuilder#[]` and `#[]=` are deprecated in favor of `#column(name)` and `#add_column`; will be removed in version 0.2.0.
|
|
238
|
+
- `TableBuilder#total_row`, `#total_row=`, `#total_row_count`, and `#total_row_count=` are deprecated in favor of `totals_row`, `totals_row=`, `totals_row_count`, and `totals_row_count=`; will be removed in version 0.2.0.
|
|
239
|
+
- `Elements::Styles#num_fmt` is deprecated in favor of `Styles#number_format_code`; will be removed in version 0.2.0.
|
|
240
|
+
- `Elements::Dxf#num_fmt` is deprecated in favor of `Dxf#number_format`; will be removed in version 0.2.0.
|
|
241
|
+
- `Elements::SheetProperties#page_setup_pr` is deprecated in favor of `SheetProperties#page_setup_properties`; will be removed in version 0.2.0.
|
|
242
|
+
- `StreamSheet#first_column` and `StreamSheet#last_column` are deprecated in favor of `column_range`; will be removed in version 0.2.0.
|
|
243
|
+
- `StreamSheet#sheet_views`, `#first_column_index`, `#last_column_index`, `#legacy_drawing`, and `#ext_lst` are deprecated in favor of `#sheet_view` and `#column_range`; will be removed in version 0.2.0.
|
|
244
|
+
- `Elements::Worksheet#conditional_formatting` and `StreamSheet#conditional_formatting` are deprecated in favor of `conditional_formats`; will be removed in version 0.2.0.
|
|
245
|
+
- `Elements::Row#to_a` and `StreamRow#to_a` returning cell values are deprecated in favor of `row.values`; in version 0.2.0, `to_a` will return `Array[Elements::Cell]` to conform to `Enumerable#to_a`.
|
|
246
|
+
- Non-predicate boolean queries on element readers (`trim_empty_rows`, `pad_empty_rows`, `pad_empty_cells`, `fit_to_page`, `show_sheet_tabs`, `full_calc_on_load`) are deprecated in favor of `?`-suffixed methods (`trim_empty_rows?`, `pad_empty_rows?`, `pad_empty_cells?`, `fit_to_page?`, `show_sheet_tabs?`, `full_calc_on_load?`); will be removed in version 0.2.0.
|
|
247
|
+
- Transitional aliases `to_workbook` on `Workbook`, `to_worksheet` on `Worksheet` and `StreamSheet`, and `each_sheet` on `Workbook` are deprecated in favor of `load` and `each`; will be removed in version 0.2.0.
|
|
248
|
+
- Style aliases `Styles#xf`, `Styles#format_code_for`, `Styles#classification_for`, and `StyleBuilder#num_fmt` are deprecated in favor of `cell_xf`, `number_format`, and `format_type`; will be removed in version 0.2.0.
|
|
249
|
+
- `Xlsxrb.modify` is deprecated in favor of explicit `Xlsxrb.load` -> mutate -> `Xlsxrb.write` pipeline; will be removed in version 0.2.0.
|
|
250
|
+
- `Xlsxrb.write_workbook` and `Xlsxrb.workbook_to_data` are deprecated in favor of `Xlsxrb.write`; will be removed in version 0.2.0.
|
|
251
|
+
- In-memory `Elements::Workbook#close`, `Elements::Worksheet#close`, and `Elements::Worksheet#load` are deprecated; will be removed in version 0.2.0 (`StreamSheet#close` and `StreamSheet#load` remain supported).
|
|
252
|
+
- Returning non-`Elements::Workbook` values from `Xlsxrb.modify` blocks is deprecated and will raise `TypeError` in version 0.2.0.
|
|
253
|
+
|
|
254
|
+
### Fixed
|
|
255
|
+
- Prevent attribute loss in `Elements::PivotTable`, `Elements::TableColumn`, `Elements::ThreadedComment`, `Elements::Comment`, and `Elements::FilterColumn` by retaining full schema attributes and capturing unmapped keyword options into `options:`.
|
|
256
|
+
- Eliminate internal calls to deprecated `MetadataRecord#[]`, `#merge`, and `cols:` across `WorksheetBuilder`, `WorkbookBuilder`, `StreamSheet`, `Elements::Worksheet`, and `Elements::Styles`.
|
|
2
257
|
|
|
3
258
|
## [0.1.17] - 2026-11-01
|
|
4
259
|
|
data/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Maintaining a gem that supports both reading and writing across streaming and in
|
|
|
36
36
|
- Streaming Support: Low-memory row streaming for reading and writing spreadsheets ($O(1)$ memory on reads; writes buffer unique shared strings).
|
|
37
37
|
- OpenXML Interoperability: Compliant with ISO/IEC 29500 (ECMA-376) and validated against the Microsoft [Open XML SDK](https://github.com/dotnet/Open-XML-SDK).
|
|
38
38
|
- AI-Assisted Maintenance: Uses AI coding agents for automated quality assurance and verification workflows. Operational guidelines are defined in [AGENTS.md](AGENTS.md).
|
|
39
|
-
- Ruby 4
|
|
39
|
+
- Ruby 3.4+: Requires Ruby 3.4 or higher.
|
|
40
40
|
|
|
41
41
|
### Autonomous Quality Assurance
|
|
42
42
|
|
|
@@ -49,6 +49,8 @@ bundle add xlsxrb
|
|
|
49
49
|
# Or without Bundler: gem install xlsxrb
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
Upgrading from 0.1.x: see [docs/UPGRADING-0.2.md](docs/UPGRADING-0.2.md) for removed APIs, their replacements, and changed defaults.
|
|
53
|
+
|
|
52
54
|
## Interactive Playground (WebAssembly)
|
|
53
55
|
|
|
54
56
|
Try `xlsxrb` directly in your browser without installing anything!
|
|
@@ -63,9 +65,37 @@ You can also browse 80+ rendered visual examples across all features in the [Vis
|
|
|
63
65
|
|
|
64
66
|
## Usage
|
|
65
67
|
|
|
66
|
-
###
|
|
68
|
+
### I/O Architecture Matrix
|
|
69
|
+
|
|
70
|
+
xlsxrb provides four canonical entry points organized along two axes:
|
|
71
|
+
|
|
72
|
+
| Axis | Streaming ($O(1)$ Memory) | In-Memory (Full Random Access) |
|
|
73
|
+
| :--- | :--- | :--- |
|
|
74
|
+
| Read / Input | `Xlsxrb.read(source) { \|sheet\| ... }` | `Xlsxrb.load(source) -> Elements::Workbook` |
|
|
75
|
+
| Write / Output | `Xlsxrb.write(dest) { \|writer\| ... }` | `Xlsxrb.build { \|builder\| ... } -> Elements::Workbook` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### Streaming Read ($O(1)$ Memory)
|
|
80
|
+
|
|
81
|
+
Iterates rows sequentially without loading the full document into memory. Closes the underlying archive automatically upon block completion:
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
require "xlsxrb"
|
|
85
|
+
|
|
86
|
+
Xlsxrb.read("large_file.xlsx") do |sheet|
|
|
87
|
+
sheet.each_row do |row|
|
|
88
|
+
row.each_cell do |cell|
|
|
89
|
+
puts "#{cell.ref}: #{cell.value}"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Streaming Write (Low Memory)
|
|
96
|
+
|
|
97
|
+
Pipes row and cell XML directly to the archive without buffering rows in memory:
|
|
67
98
|
|
|
68
|
-
#### Streaming Write (Low Memory)
|
|
69
99
|
```ruby
|
|
70
100
|
require "xlsxrb"
|
|
71
101
|
|
|
@@ -78,25 +108,25 @@ Xlsxrb.write("large_output.xlsx") do |writer|
|
|
|
78
108
|
end
|
|
79
109
|
```
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
### In-Memory Load (Full Random Access)
|
|
112
|
+
|
|
113
|
+
Parses the workbook into an immutable document model (`Elements::Workbook`) and immediately closes the underlying file:
|
|
83
114
|
|
|
84
|
-
#### Streaming Read ($O(1)$ Memory)
|
|
85
115
|
```ruby
|
|
86
116
|
require "xlsxrb"
|
|
87
117
|
|
|
88
|
-
Xlsxrb.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
end
|
|
118
|
+
wb = Xlsxrb.load("workbook.xlsx")
|
|
119
|
+
sheet = wb["Sheet1"]
|
|
120
|
+
|
|
121
|
+
puts sheet["A1"].value
|
|
122
|
+
puts sheet.page_setup.orientation
|
|
123
|
+
puts sheet.hyperlinks["B2"].url
|
|
95
124
|
```
|
|
96
125
|
|
|
97
|
-
### In-Memory
|
|
126
|
+
### In-Memory Build (Document Creation)
|
|
127
|
+
|
|
128
|
+
Constructs an in-memory `Elements::Workbook` using the declarative builder DSL:
|
|
98
129
|
|
|
99
|
-
#### Creating & Exporting (Rails / Mailers)
|
|
100
130
|
```ruby
|
|
101
131
|
require "xlsxrb"
|
|
102
132
|
|
|
@@ -112,18 +142,54 @@ Xlsxrb.write("report.xlsx", wb)
|
|
|
112
142
|
binary_data = Xlsxrb.write(wb)
|
|
113
143
|
```
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### Constant-Memory Streaming Transformation
|
|
148
|
+
|
|
149
|
+
To transform or filter data from an existing spreadsheet, stream rows from reader to writer in $O(1)$ memory:
|
|
150
|
+
|
|
116
151
|
```ruby
|
|
117
152
|
require "xlsxrb"
|
|
118
153
|
|
|
119
|
-
Xlsxrb.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
154
|
+
Xlsxrb.write("output.xlsx") do |out_wb|
|
|
155
|
+
out_wb.sheet("Processed") do |out_sheet|
|
|
156
|
+
Xlsxrb.read("input.xlsx") do |in_sheet|
|
|
157
|
+
in_sheet.each_row do |row|
|
|
158
|
+
# type_cast: true turns date-formatted cells into Date/Time (so they are not
|
|
159
|
+
# scaled as numbers) and keeps empty cells as nil in their column.
|
|
160
|
+
out_sheet.row(row.values(type_cast: true).map { |v| v.is_a?(Numeric) ? v * 1.1 : v })
|
|
161
|
+
end
|
|
162
|
+
end
|
|
123
163
|
end
|
|
124
164
|
end
|
|
125
165
|
```
|
|
126
166
|
|
|
167
|
+
This copies cell values only. Styles, number formats other than dates, formulas, merged cells, and column widths are not carried over; set them on the writer if the output needs them.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### Template Migration & AI Code Generation
|
|
172
|
+
|
|
173
|
+
> [!NOTE]
|
|
174
|
+
> `Xlsxrb.modify` was removed in 0.2.0 in favor of `Xlsxrb.read` -> `Xlsxrb.write` and `Xlsxrb.load`. Runtime data transformations are handled with streaming pipelines (`Xlsxrb.read` -> `Xlsxrb.write`), while template-based report generation is performed by converting templates into declarative `Xlsxrb.write` DSL scripts.
|
|
175
|
+
|
|
176
|
+
To migrate an existing Excel template (`template.xlsx`) into reproducible Ruby code, inspect the template structure with `Xlsxrb.load` and provide it to an AI coding assistant:
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
require "xlsxrb"
|
|
180
|
+
|
|
181
|
+
wb = Xlsxrb.load("template.xlsx")
|
|
182
|
+
sheet = wb.sheets.first
|
|
183
|
+
|
|
184
|
+
# Inspect layout, formulas, and column widths
|
|
185
|
+
puts "Columns: #{sheet.columns.map { |c| [c.index, c.width] }}"
|
|
186
|
+
puts "Merged: #{sheet.merged_cells}"
|
|
187
|
+
puts "Formulas: #{sheet.rows.flat_map(&:cells).select(&:formula?).map { |c| [c.ref, c.formula] }}"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Recommended AI Prompt for Template Migration:**
|
|
191
|
+
> "Convert this Excel template into an `Xlsxrb.write` builder script using xlsxrb DSL methods (`row`, `column`, `merge`, `style`, `formula`). Ensure cell styles, column widths, number formats, and formulas match the inspected template layout."
|
|
192
|
+
|
|
127
193
|
### Password Protection & Encryption ([MS-OFFCRYPTO])
|
|
128
194
|
|
|
129
195
|
Natively supports reading and writing encrypted XLSX files (Standard & Agile Encryption) with zero external C-extensions:
|
|
@@ -144,18 +210,35 @@ end
|
|
|
144
210
|
|
|
145
211
|
### Date and Time Handling
|
|
146
212
|
|
|
147
|
-
Excel stores dates and times as
|
|
213
|
+
Excel stores dates and times as serial numbers (days since 1900, with the time of day as the fraction) and marks them as dates only through the cell's number format. `cell.value` returns that serial number as an Integer or Float. To get dates back:
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
Xlsxrb.read("input.xlsx") do |sheet|
|
|
217
|
+
sheet.each_row do |row|
|
|
218
|
+
row.values(type_cast: true) # => ["Due", #<Date: 2026-01-02>, 2026-01-02 03:04:05 UTC]
|
|
219
|
+
|
|
220
|
+
row.cells.each do |cell|
|
|
221
|
+
next unless cell.date_format?
|
|
148
222
|
|
|
149
|
-
|
|
223
|
+
cell.to_date # => Date
|
|
224
|
+
cell.to_time # => Time in UTC
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
When writing, `Date`, `Time`, and `DateTime` values get a date or date-time number format automatically, also when the cell has a style without its own `number_format`.
|
|
231
|
+
|
|
232
|
+
Serial numbers carry no timezone, so `to_time` returns the wall-clock time as UTC. To interpret it in an application timezone (such as JST or America/New_York), build a local time from its components:
|
|
150
233
|
|
|
151
234
|
```ruby
|
|
235
|
+
t = cell.to_time
|
|
236
|
+
|
|
152
237
|
# With ActiveSupport / Rails:
|
|
153
|
-
local_time = Time.zone.local(
|
|
154
|
-
cell.value.hour, cell.value.min, cell.value.sec)
|
|
238
|
+
local_time = Time.zone.local(t.year, t.month, t.day, t.hour, t.min, t.sec)
|
|
155
239
|
|
|
156
240
|
# With Ruby standard library:
|
|
157
|
-
local_time = Time.local(
|
|
158
|
-
cell.value.hour, cell.value.min, cell.value.sec)
|
|
241
|
+
local_time = Time.local(t.year, t.month, t.day, t.hour, t.min, t.sec)
|
|
159
242
|
```
|
|
160
243
|
|
|
161
244
|
### IDE Autocompletion & Ruby LSP Support
|
|
@@ -176,7 +259,7 @@ For full details, see [docs/SPEC_SOURCES.md](docs/SPEC_SOURCES.md).
|
|
|
176
259
|
|
|
177
260
|
## Benchmarks
|
|
178
261
|
|
|
179
|
-
Benchmark processing 1,000,000 cells (100,000 rows × 10 cols) across popular Ruby gems:
|
|
262
|
+
Benchmark processing 1,000,000 cells (100,000 rows × 10 cols) across popular Ruby gems, with YJIT enabled for every library (Rails 7.2 and later enable YJIT by default):
|
|
180
263
|
|
|
181
264
|
<p align="center">
|
|
182
265
|
<img src="docs/assets/benchmark_results.svg" width="100%" alt="Ruby XLSX Performance Benchmarks"/>
|
|
@@ -184,7 +267,7 @@ Benchmark processing 1,000,000 cells (100,000 rows × 10 cols) across popular Ru
|
|
|
184
267
|
|
|
185
268
|
For detailed metrics (peak memory, GC count, mean/median times) and architectural tradeoffs (SST vs. Inline Strings), see [docs/PEER_LIBRARIES.md](docs/PEER_LIBRARIES.md).
|
|
186
269
|
|
|
187
|
-
To reproduce locally: `ruby benchmark.rb 100000 10`
|
|
270
|
+
To reproduce locally: `RUBY_YJIT_ENABLE=1 ruby benchmark.rb 100000 10`
|
|
188
271
|
|
|
189
272
|
## Quality Assurance & Testing
|
|
190
273
|
|