fast_xlsx 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd683d252e7a6aa1e682a600b6ac80c688487ae21d6ef1e38545b4bd177ecb00
4
- data.tar.gz: 8785f8bfa9840f45a6f6e59d352b85ebaddccad7609b64ecabc68db297bf213a
3
+ metadata.gz: 85532243a1cd812798374658f4b5673ea9cda88586e876b76281f99cbd8dd065
4
+ data.tar.gz: 67747bd17f6f4ecf7ed9041767498de5d0d3d416922250578bf5b87c0d41ad1c
5
5
  SHA512:
6
- metadata.gz: dc2e931966753abf23eac73a2ed20e900e4840dcc1a83664939980bfd53d21ccf4f56e4a40bf3b322dde05f1f860c131ec1a09b3c3e878f52caa4e082ce6df32
7
- data.tar.gz: 9e375f7510642255093ffe25d84fa0ea39e2d7da1ba23d73e2672c55be39dac79b342501b58d845167f99ce4614d03bd2d4c1649d1217b064557cc1c1ab05b58
6
+ metadata.gz: 75d89ae4b66fce6129f09d8ba18d1766571fe740e3069eebc9be5334dbd254f5a75dbccf56c3d250a6a0deacfa109d86971b0974289d0822467b8971d6b3d40c
7
+ data.tar.gz: e9ff13d9d4014d5b2034ffdff56897d87ff00df6688145c6ae4bc637690323389ccd53c4c8e651e5da5177fb06ba2f141f96a3fe9dc60e0949ce69672984edb4
data/CHANGELOG.md CHANGED
@@ -1,10 +1,40 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2026-10-01
4
+
5
+ ### Added
6
+
7
+ - Range methods (`autofilter`, `merge_range`, `conditional_format`, `data_validation`, `add_table`) also take an Excel reference (`"A1:D10"`) or rows and columns as Integers or Ranges (`0..9, 0..3`).
8
+ - `Workbook#define_name` for workbook-wide and sheet-scoped defined names.
9
+ - `Worksheet#group_rows` and `#group_columns` (outline groups, optionally collapsed); `group_rows` raises in `:constant` / `:low` mode.
10
+ - `Worksheet#protect(password:, allow:)` locks a sheet; `Format` options `locked: false` and `hidden: true` keep cells editable or hide formulas.
11
+
12
+ ### Changed
13
+
14
+ - `column_width`, `column_format` and the other methods that take a Range raise `ArgumentError` for an empty, reversed or endless Range, or one that isn't Integers, instead of a `TypeError` or `RangeError`.
15
+
16
+ ## [0.1.2] - 2026-09-30
17
+
18
+ ### Fixed
19
+
20
+ - Values Excel cannot hold (a string over 32,767 characters, invalid UTF-8, a bad or over-long URL, more than 16,384 columns) raise before anything is written, instead of leaving the row half written.
21
+ - `merge_range` with such a value no longer leaves the range merged; its value also takes its table column's format.
22
+ - An unnamed worksheet takes the first free `SheetN` instead of a name that clashes with one given earlier (which failed only when saving).
23
+ - Cell values and formats are copied out of Ruby objects when a row is converted, so Ruby code run while converting (a `to_s`) cannot change or free them before they are written.
24
+ - Ruby code run while converting a value (a `to_s`, `jd`, ...) that touches the same workbook, or another thread writing to it, no longer deadlocks. A value that fails to convert leaves its row unwritten.
25
+ - In `:constant` / `:low` mode, `merge_range` and `add_table` on rows already written to disk raise `FastXlsx::Error` instead of being dropped; cells beside a tall merge can still be written.
26
+ - Table column formats apply to rows written after `add_table`.
27
+ - Invalid worksheet names raise without leaving an extra sheet behind; names that differ only in case raise at `add_worksheet`, not at save.
28
+ - Strings in other encodings (e.g. Windows-1252) are converted to UTF-8.
29
+ - `data_validation` lists accept numbers and other values (listed by `to_s`).
30
+ - Dates match Excel's 1900 date system (serials before 1900-03-01 were one too high); dates before 1900 raise `ArgumentError`.
31
+ - `Workbook#save` accepts a `Pathname`.
32
+
3
33
  ## [0.1.1] - 2026-09-30
4
34
 
5
35
  ### Fixed
6
36
 
7
- - Precompiled (platform) gems failed to `require`: the extension was only looked up where a source install puts it, not in the per-Ruby-version directory that platform gems use. 0.1.0 is yanked; upgrade to 0.1.1.
37
+ - Precompiled (platform) gems failed to `require`: the extension was only looked up where a source install puts it, not in the per-Ruby-version directory that platform gems use. 0.1.0's platform gems cannot be loaded; upgrade to 0.1.1 (`bundle update fast_xlsx` if your lockfile has 0.1.0).
8
38
 
9
39
  ### Changed
10
40
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # FastXlsx
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/fast_xlsx.svg)](https://badge.fury.io/rb/fast_xlsx)
3
4
  [![codecov](https://codecov.io/gh/7a6163/fast_xlsx/graph/badge.svg)](https://codecov.io/gh/7a6163/fast_xlsx)
4
5
 
5
6
  Fast `.xlsx` writer for Ruby, built on [rust_xlsxwriter](https://github.com/jmcnamara/rust_xlsxwriter) via [magnus](https://github.com/matsadler/magnus).
@@ -75,6 +76,8 @@ ws.write(1, 2, Date.today, date) # format one cell
75
76
  | `valign` | `:top`, `:center`, `:bottom` |
76
77
  | `border`, `border_left`, `border_right`, `border_top`, `border_bottom` | `:thin`, `:medium`, `:thick`, `:dashed`, `:dotted`, `:double`, `:hair` |
77
78
  | `border_color` | `"#RRGGBB"` or `0xRRGGBB` |
79
+ | `locked` | `false` keeps the cell editable on a protected sheet (default `true`) |
80
+ | `hidden` | `true` hides the cell's formula on a protected sheet |
78
81
 
79
82
  Per-side borders override `border`. Unknown options and invalid values raise `ArgumentError`.
80
83
 
@@ -85,7 +88,18 @@ ws.column_width(0, 20) # column A, width in characters
85
88
  ws.column_width(1..3, 12) # columns B–D
86
89
  ws.column_format(4, FastXlsx::Format.new(num_format: "#,##0.00")) # default for cells in E written without a format
87
90
  ws.autofit # size other columns to the data written so far; set widths are kept
88
- ws.autofilter(0, 0, 100, 3) # filter buttons on A1:D101 (first_row, first_col, last_row, last_col)
91
+ ws.autofilter("A1:D101") # filter buttons on A1:D101
92
+ ```
93
+
94
+ ### Cell ranges
95
+
96
+ `autofilter`, `merge_range`, `conditional_format`, `data_validation` and `add_table` take a range in any of these styles:
97
+
98
+ ```ruby
99
+ ws.autofilter(0, 0, 100, 3) # four 0-based numbers: first_row, first_col, last_row, last_col
100
+ ws.autofilter("A1:D101") # an Excel reference; "$A$1:$D$101" and a single "B2" work too
101
+ ws.autofilter(0..100, 0..3) # rows and columns, each an Integer or a Range
102
+ ws.merge_range(0, 0..3, "Q3 report", title) # row 1, columns A–D
89
103
  ```
90
104
 
91
105
  `autofit` only sees rows still in memory, so in `:constant` / `:low` memory mode it ignores rows already written to disk; set widths with `column_width` instead.
@@ -103,6 +117,36 @@ ws.page_footer("&L&A", margin: 0.2) # sheet name on the left; margin
103
117
  ws.margins(left: 0.5, top: 1) # other margins keep Excel's defaults
104
118
  ```
105
119
 
120
+ ### Outline groups
121
+
122
+ ```ruby
123
+ ws.group_rows(1..10) # rows 2–11 get an expand/collapse button
124
+ ws.group_rows(1..4) # grouping again nests them (up to 7 levels)
125
+ ws.group_columns(2..3, collapsed: true) # columns C–D, collapsed until expanded
126
+ ```
127
+
128
+ `group_rows` needs `memory: :standard`: in `:constant` / `:low` mode rust_xlsxwriter writes rows without their outline level, so it raises. `group_columns` works in every mode.
129
+
130
+ ### Defined names
131
+
132
+ ```ruby
133
+ wb.define_name("Rate", "=0.96") # workbook-wide; use as =A1*Rate
134
+ wb.define_name("Report!Sales", "=Report!$B$2:$B$13") # only on the Report sheet
135
+ ```
136
+
137
+ Invalid names raise `FastXlsx::Error` right away; duplicate names, and names for a sheet that doesn't exist, raise when saving.
138
+
139
+ ### Protection
140
+
141
+ ```ruby
142
+ input = FastXlsx::Format.new(locked: false)
143
+ ws.write(1, 1, 0, input) # B2 stays editable
144
+ ws.protect # lock everything else
145
+ ws.protect(password: "secret", allow: %i[sort use_autofilter]) # or with a password and allowed actions
146
+ ```
147
+
148
+ `allow:` takes `:format_cells`, `:format_columns`, `:format_rows`, `:insert_columns`, `:insert_rows`, `:insert_links`, `:delete_columns`, `:delete_rows`, `:sort`, `:use_autofilter`, `:use_pivot_tables`, `:edit_scenarios`, `:edit_objects`. The password only stops editing in Excel; it does not encrypt the file.
149
+
106
150
  ### Conditional formats
107
151
 
108
152
  ```ruby
@@ -276,6 +320,15 @@ cargo llvm-cov report --release # or --lcov / --html
276
320
 
277
321
  Rebuild in a clean shell afterwards (`rm -rf tmp && bundle exec rake compile`) so the everyday build is not instrumented.
278
322
 
323
+ Mutation tests ([cargo-mutants](https://mutants.rs)) change the Rust source one small edit at a time and check that a Ruby test fails for each change. `ext/fast_xlsx/tests/ruby_suite.rs` is what connects the two: it rebuilds the extension and runs the Ruby suite, so `cargo test` covers the Ruby tests too.
324
+
325
+ ```bash
326
+ cargo install cargo-mutants
327
+ cargo mutants --file ext/fast_xlsx/src/lib.rs --jobs 4 # ~7 minutes; results in mutants.out/
328
+ ```
329
+
330
+ Mutants listed in `mutants.out/missed.txt` point at behaviour no test checks. The `Mutation tests` workflow runs this weekly and on demand.
331
+
279
332
  ### Releasing
280
333
 
281
334
  First generate the showcase workbook and open it in Excel to check every feature renders (the test suite only inspects the XML):
data/bench/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- fast_xlsx (0.1.1)
4
+ fast_xlsx (0.2.0)
5
5
  rb_sys (~> 0.9.130)
6
6
 
7
7
  GEM
@@ -77,7 +77,7 @@ DEPENDENCIES
77
77
  CHECKSUMS
78
78
  caxlsx (4.5.0) sha256=e3d98d859f148df05d5462086b5079b523f29c1766b569535f1d68629ce743ff
79
79
  fast_excel (0.5.0) sha256=59c418bdcf586a6030798d4e3a9f575742badaceaf7bb90f38eee5feb5bdc478
80
- fast_xlsx (0.1.1)
80
+ fast_xlsx (0.2.0)
81
81
  ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df
82
82
  ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39
83
83
  ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564