xlsxrb 0.1.9 → 0.1.10
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 +71 -253
- data/Rakefile +2 -1
- data/docs/PEER_LIBRARIES.md +121 -0
- data/docs/assets/benchmark_results.svg +144 -0
- data/docs/assets/lsp_autocompletion.png +0 -0
- data/docs/assets/playground_preview.png +0 -0
- data/docs/visual/VisualGallery.md +183 -0
- data/docs/wasm/ruby.wasm +0 -0
- data/lib/xlsxrb/chart_builder.rb +333 -0
- data/lib/xlsxrb/elements/workbook.rb +2 -2
- data/lib/xlsxrb/ooxml/reader/listeners.rb +6450 -0
- data/lib/xlsxrb/ooxml/reader.rb +2 -6438
- data/lib/xlsxrb/ooxml/workbook_writer.rb +10 -10
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +161 -116
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +5 -1
- data/lib/xlsxrb/stream_row.rb +5 -3
- data/lib/xlsxrb/stream_sheet.rb +125 -0
- data/lib/xlsxrb/stream_writer.rb +1646 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/workbook_builder.rb +309 -0
- data/lib/xlsxrb/worksheet_builder.rb +691 -0
- data/lib/xlsxrb.rb +238 -2968
- data/sig/generated/xlsxrb/chart_builder.rbs +269 -0
- data/sig/generated/xlsxrb/ooxml/reader/listeners.rbs +1074 -0
- data/sig/generated/xlsxrb/ooxml/reader.rbs +0 -1067
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +3 -3
- data/sig/generated/xlsxrb/stream_row.rbs +3 -2
- data/sig/generated/xlsxrb/stream_sheet.rbs +100 -0
- data/sig/generated/xlsxrb/stream_writer.rbs +954 -0
- data/sig/generated/xlsxrb/workbook_builder.rbs +146 -0
- data/sig/generated/xlsxrb/worksheet_builder.rbs +349 -0
- data/sig/generated/xlsxrb.rbs +103 -1563
- metadata +17 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 480" width="100%" height="100%">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
+
<stop offset="0%" stop-color="#161b22"/>
|
|
5
|
+
<stop offset="100%" stop-color="#0d1117"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
.card { fill: #161b22; stroke: #30363d; stroke-width: 1px; rx: 8px; }
|
|
11
|
+
.title { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 700; fill: #f0f6fc; }
|
|
12
|
+
.subtitle { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 12px; fill: #8b949e; }
|
|
13
|
+
.section-title { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 700; fill: #e6edf3; }
|
|
14
|
+
.label { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 12px; fill: #c9d1d9; }
|
|
15
|
+
.label-accent { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 700; fill: #58a6ff; }
|
|
16
|
+
.value { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 11px; font-weight: 600; fill: #ffffff; }
|
|
17
|
+
.grid { stroke: #21262d; stroke-width: 1px; stroke-dasharray: 4 4; }
|
|
18
|
+
.footer { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 11px; fill: #8b949e; }
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<!-- Container -->
|
|
22
|
+
<rect width="960" height="480" rx="12" fill="url(#bg-grad)" stroke="#30363d" stroke-width="1"/>
|
|
23
|
+
|
|
24
|
+
<!-- Main Header -->
|
|
25
|
+
<text x="480" y="38" text-anchor="middle" class="title">Ruby XLSX Performance Benchmarks (1,000,000 Cells)</text>
|
|
26
|
+
<text x="480" y="58" text-anchor="middle" class="subtitle">100,000 rows × 10 cols • Mixed business data • Linear time scale (0s – 40s)</text>
|
|
27
|
+
|
|
28
|
+
<!-- Left: Write Performance -->
|
|
29
|
+
<g transform="translate(35, 75)">
|
|
30
|
+
<rect width="430" height="350" class="card"/>
|
|
31
|
+
<text x="20" y="30" class="section-title">Write Execution Time</text>
|
|
32
|
+
<text x="20" y="46" font-family="sans-serif" font-size="10" fill="#8b949e">Time to generate 1M cells (Lower is faster)</text>
|
|
33
|
+
|
|
34
|
+
<line x1="160.0" y1="65" x2="160.0" y2="320" class="grid"/>
|
|
35
|
+
<text x="160.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">0s</text>
|
|
36
|
+
|
|
37
|
+
<line x1="215.0" y1="65" x2="215.0" y2="320" class="grid"/>
|
|
38
|
+
<text x="215.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">10s</text>
|
|
39
|
+
|
|
40
|
+
<line x1="270.0" y1="65" x2="270.0" y2="320" class="grid"/>
|
|
41
|
+
<text x="270.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">20s</text>
|
|
42
|
+
|
|
43
|
+
<line x1="325.0" y1="65" x2="325.0" y2="320" class="grid"/>
|
|
44
|
+
<text x="325.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">30s</text>
|
|
45
|
+
|
|
46
|
+
<line x1="380.0" y1="65" x2="380.0" y2="320" class="grid"/>
|
|
47
|
+
<text x="380.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">40s</text>
|
|
48
|
+
|
|
49
|
+
<!-- xlsxtream 3.1.0: 1.19s -->
|
|
50
|
+
<text x="150" y="85" text-anchor="end" class="label">xlsxtream 3.1.0</text>
|
|
51
|
+
<rect x="160" y="72" width="6.5" height="18" rx="3" fill="#64748b"/>
|
|
52
|
+
<text x="174.5" y="85" class="value">1.19 s</text>
|
|
53
|
+
|
|
54
|
+
<!-- xlsxrb (Streaming): 1.73s -->
|
|
55
|
+
<text x="150" y="120" text-anchor="end" class="label-accent">xlsxrb (Streaming)</text>
|
|
56
|
+
<rect x="160" y="107" width="9.5" height="18" rx="3" fill="#3b82f6"/>
|
|
57
|
+
<text x="177.5" y="120" class="value">1.73 s</text>
|
|
58
|
+
|
|
59
|
+
<!-- fast_excel 0.5.0: 1.89s -->
|
|
60
|
+
<text x="150" y="155" text-anchor="end" class="label">fast_excel 0.5.0</text>
|
|
61
|
+
<rect x="160" y="142" width="10.4" height="18" rx="3" fill="#64748b"/>
|
|
62
|
+
<text x="178.4" y="155" class="value">1.89 s</text>
|
|
63
|
+
|
|
64
|
+
<!-- xlsxrb (In-Memory): 3.84s -->
|
|
65
|
+
<text x="150" y="190" text-anchor="end" class="label-accent">xlsxrb (In-Memory)</text>
|
|
66
|
+
<rect x="160" y="177" width="21.1" height="18" rx="3" fill="#3b82f6"/>
|
|
67
|
+
<text x="189.1" y="190" class="value">3.84 s</text>
|
|
68
|
+
|
|
69
|
+
<!-- write_xlsx 1.15.0: 4.32s -->
|
|
70
|
+
<text x="150" y="225" text-anchor="end" class="label">write_xlsx 1.15.0</text>
|
|
71
|
+
<rect x="160" y="212" width="23.8" height="18" rx="3" fill="#64748b"/>
|
|
72
|
+
<text x="191.8" y="225" class="value">4.32 s</text>
|
|
73
|
+
|
|
74
|
+
<!-- caxlsx 4.5.0: 5.15s -->
|
|
75
|
+
<text x="150" y="260" text-anchor="end" class="label">caxlsx 4.5.0</text>
|
|
76
|
+
<rect x="160" y="247" width="28.3" height="18" rx="3" fill="#64748b"/>
|
|
77
|
+
<text x="196.3" y="260" class="value">5.15 s</text>
|
|
78
|
+
|
|
79
|
+
<!-- rubyXL 3.4.38: 38.81s -->
|
|
80
|
+
<text x="150" y="295" text-anchor="end" class="label">rubyXL 3.4.38</text>
|
|
81
|
+
<rect x="160" y="282" width="213.5" height="18" rx="3" fill="#64748b"/>
|
|
82
|
+
<text x="381.5" y="295" class="value">38.81 s</text>
|
|
83
|
+
</g>
|
|
84
|
+
|
|
85
|
+
<!-- Right: Read Performance -->
|
|
86
|
+
<g transform="translate(495, 75)">
|
|
87
|
+
<rect width="430" height="350" class="card"/>
|
|
88
|
+
<text x="20" y="30" class="section-title">Read Execution Time</text>
|
|
89
|
+
<text x="20" y="46" font-family="sans-serif" font-size="10" fill="#8b949e">Time to parse 1M cells (Lower is faster)</text>
|
|
90
|
+
|
|
91
|
+
<line x1="160.0" y1="65" x2="160.0" y2="320" class="grid"/>
|
|
92
|
+
<text x="160.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">0s</text>
|
|
93
|
+
|
|
94
|
+
<line x1="215.0" y1="65" x2="215.0" y2="320" class="grid"/>
|
|
95
|
+
<text x="215.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">10s</text>
|
|
96
|
+
|
|
97
|
+
<line x1="270.0" y1="65" x2="270.0" y2="320" class="grid"/>
|
|
98
|
+
<text x="270.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">20s</text>
|
|
99
|
+
|
|
100
|
+
<line x1="325.0" y1="65" x2="325.0" y2="320" class="grid"/>
|
|
101
|
+
<text x="325.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">30s</text>
|
|
102
|
+
|
|
103
|
+
<line x1="380.0" y1="65" x2="380.0" y2="320" class="grid"/>
|
|
104
|
+
<text x="380.0" y="335" font-family="sans-serif" font-size="10" fill="#64748b" text-anchor="middle">40s</text>
|
|
105
|
+
|
|
106
|
+
<!-- xlsxrb (Streaming): 3.17s -->
|
|
107
|
+
<text x="150" y="85" text-anchor="end" class="label-accent">xlsxrb (Streaming)</text>
|
|
108
|
+
<rect x="160" y="72" width="17.4" height="18" rx="3" fill="#3b82f6"/>
|
|
109
|
+
<text x="185.4" y="85" class="value">3.17 s</text>
|
|
110
|
+
|
|
111
|
+
<!-- simple_xlsx_reader: 4.48s -->
|
|
112
|
+
<text x="150" y="120" text-anchor="end" class="label">simple_xlsx_reader</text>
|
|
113
|
+
<rect x="160" y="107" width="24.6" height="18" rx="3" fill="#64748b"/>
|
|
114
|
+
<text x="192.6" y="120" class="value">4.48 s</text>
|
|
115
|
+
|
|
116
|
+
<!-- xlsxrb (In-Memory): 5.71s -->
|
|
117
|
+
<text x="150" y="155" text-anchor="end" class="label-accent">xlsxrb (In-Memory)</text>
|
|
118
|
+
<rect x="160" y="142" width="31.4" height="18" rx="3" fill="#3b82f6"/>
|
|
119
|
+
<text x="199.4" y="155" class="value">5.71 s</text>
|
|
120
|
+
|
|
121
|
+
<!-- creek 2.6.3: 8.14s -->
|
|
122
|
+
<text x="150" y="190" text-anchor="end" class="label">creek 2.6.3</text>
|
|
123
|
+
<rect x="160" y="177" width="44.8" height="18" rx="3" fill="#64748b"/>
|
|
124
|
+
<text x="212.8" y="190" class="value">8.14 s</text>
|
|
125
|
+
|
|
126
|
+
<!-- xsv 1.4.1: 14.61s -->
|
|
127
|
+
<text x="150" y="225" text-anchor="end" class="label">xsv 1.4.1</text>
|
|
128
|
+
<rect x="160" y="212" width="80.4" height="18" rx="3" fill="#64748b"/>
|
|
129
|
+
<text x="248.4" y="225" class="value">14.61 s</text>
|
|
130
|
+
|
|
131
|
+
<!-- roo 3.0.0: 15.69s -->
|
|
132
|
+
<text x="150" y="260" text-anchor="end" class="label">roo 3.0.0</text>
|
|
133
|
+
<rect x="160" y="247" width="86.3" height="18" rx="3" fill="#64748b"/>
|
|
134
|
+
<text x="254.3" y="260" class="value">15.69 s</text>
|
|
135
|
+
|
|
136
|
+
<!-- rubyXL 3.4.38: 37.13s -->
|
|
137
|
+
<text x="150" y="295" text-anchor="end" class="label">rubyXL 3.4.38</text>
|
|
138
|
+
<rect x="160" y="282" width="204.2" height="18" rx="3" fill="#64748b"/>
|
|
139
|
+
<text x="372.2" y="295" class="value">37.13 s</text>
|
|
140
|
+
</g>
|
|
141
|
+
|
|
142
|
+
<!-- Footer -->
|
|
143
|
+
<text x="480" y="455" text-anchor="middle" class="footer">Tested on Ruby 3.4+ in isolated subprocesses • Full GC and peak memory metrics in docs/PEER_LIBRARIES.md</text>
|
|
144
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -251,6 +251,11 @@ This gallery showcases `xlsxrb` DSL usage side-by-side with the visual rendering
|
|
|
251
251
|
<td align="center"><a href="#conditional-formatting">View Code & Detail</a></td>
|
|
252
252
|
</tr>
|
|
253
253
|
<tr>
|
|
254
|
+
<td><strong>Drawing Shapes</strong></td>
|
|
255
|
+
<td align="center"><img src="../../test/visual/baselines/drawing_shapes/page-1.png" width="160" alt="Drawing Shapes"/></td>
|
|
256
|
+
<td align="center"><a href="#drawing-shapes">View Code & Detail</a></td>
|
|
257
|
+
</tr>
|
|
258
|
+
<tr>
|
|
254
259
|
<td><strong>Embedded Images</strong></td>
|
|
255
260
|
<td align="center"><img src="../../test/visual/baselines/embedded_images/page-1.png" width="160" alt="Embedded Images"/></td>
|
|
256
261
|
<td align="center"><a href="#embedded-images">View Code & Detail</a></td>
|
|
@@ -361,6 +366,11 @@ This gallery showcases `xlsxrb` DSL usage side-by-side with the visual rendering
|
|
|
361
366
|
<td align="center"><a href="#page-paper-size-a3">View Code & Detail</a></td>
|
|
362
367
|
</tr>
|
|
363
368
|
<tr>
|
|
369
|
+
<td><strong>Pivot Table</strong></td>
|
|
370
|
+
<td align="center"><img src="../../test/visual/baselines/pivot_table/page-1.png" width="160" alt="Pivot Table"/></td>
|
|
371
|
+
<td align="center"><a href="#pivot-table">View Code & Detail</a></td>
|
|
372
|
+
</tr>
|
|
373
|
+
<tr>
|
|
364
374
|
<td><strong>Row Grouping</strong></td>
|
|
365
375
|
<td align="center"><img src="../../test/visual/baselines/row_grouping/page-1.png" width="160" alt="Row Grouping"/></td>
|
|
366
376
|
<td align="center"><a href="#row-grouping">View Code & Detail</a></td>
|
|
@@ -396,6 +406,11 @@ This gallery showcases `xlsxrb` DSL usage side-by-side with the visual rendering
|
|
|
396
406
|
<td align="center"><a href="#styles-fonts-fills">View Code & Detail</a></td>
|
|
397
407
|
</tr>
|
|
398
408
|
<tr>
|
|
409
|
+
<td><strong>Table Styles</strong></td>
|
|
410
|
+
<td align="center"><img src="../../test/visual/baselines/table_styles/page-1.png" width="160" alt="Table Styles"/></td>
|
|
411
|
+
<td align="center"><a href="#table-styles">View Code & Detail</a></td>
|
|
412
|
+
</tr>
|
|
413
|
+
<tr>
|
|
399
414
|
<td><strong>View Show Grid Lines</strong></td>
|
|
400
415
|
<td align="center"><img src="../../test/visual/baselines/view_show_grid_lines/page-1.png" width="160" alt="View Show Grid Lines"/></td>
|
|
401
416
|
<td align="center"><a href="#view-show-grid-lines">View Code & Detail</a></td>
|
|
@@ -2844,6 +2859,55 @@ Row 0: A1: 90, B1: 45, C1: 72, D1: 88
|
|
|
2844
2859
|
|
|
2845
2860
|
<hr/>
|
|
2846
2861
|
|
|
2862
|
+
## Drawing Shapes
|
|
2863
|
+
|
|
2864
|
+
Visual demonstration for Drawing Shapes.
|
|
2865
|
+
|
|
2866
|
+
### Rendered Output (LibreOffice Calc)
|
|
2867
|
+
|
|
2868
|
+
<div><img src="../../test/visual/baselines/drawing_shapes/page-1.png" width="100%" alt="Preview"/></div>
|
|
2869
|
+
|
|
2870
|
+
<div><img src="../../test/visual/baselines/drawing_shapes/page-2.png" width="100%" alt="Preview"/></div>
|
|
2871
|
+
|
|
2872
|
+
### DSL Code
|
|
2873
|
+
|
|
2874
|
+
```ruby
|
|
2875
|
+
# frozen_string_literal: true
|
|
2876
|
+
|
|
2877
|
+
require "xlsxrb"
|
|
2878
|
+
|
|
2879
|
+
output_path = ARGV[0] || "drawing_shapes.xlsx"
|
|
2880
|
+
|
|
2881
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2882
|
+
wb.sheet("Shapes") do |sheet|
|
|
2883
|
+
sheet.column(0..7, width: 15)
|
|
2884
|
+
sheet.row(["Diagram with shapes and annotations"])
|
|
2885
|
+
sheet.row([])
|
|
2886
|
+
sheet.shape(preset: "rect", text: "Process Start", from_col: 1, from_row: 2, to_col: 3, to_row: 4)
|
|
2887
|
+
sheet.shape(preset: "rightArrow", text: "Next", from_col: 4, from_row: 3, to_col: 5, to_row: 4)
|
|
2888
|
+
sheet.shape(preset: "roundRect", text: "Processing", from_col: 6, from_row: 2, to_col: 8, to_row: 4)
|
|
2889
|
+
end
|
|
2890
|
+
end
|
|
2891
|
+
|
|
2892
|
+
puts "=== Read Validation ==="
|
|
2893
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2894
|
+
sheet = workbook.sheets.first
|
|
2895
|
+
sheet.rows.each do |row|
|
|
2896
|
+
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
2897
|
+
puts "Row #{row.index}: #{row_cells.join(", ")}"
|
|
2898
|
+
end
|
|
2899
|
+
```
|
|
2900
|
+
|
|
2901
|
+
### Console Output
|
|
2902
|
+
|
|
2903
|
+
```text
|
|
2904
|
+
=== Read Validation ===
|
|
2905
|
+
Row 0: A1: "Diagram with shapes and annotations"
|
|
2906
|
+
Row 1:
|
|
2907
|
+
```
|
|
2908
|
+
|
|
2909
|
+
<hr/>
|
|
2910
|
+
|
|
2847
2911
|
## Embedded Images
|
|
2848
2912
|
|
|
2849
2913
|
Demonstrates embedding raster PNG images in cell ranges.
|
|
@@ -4010,6 +4074,71 @@ Print Options: {}
|
|
|
4010
4074
|
|
|
4011
4075
|
<hr/>
|
|
4012
4076
|
|
|
4077
|
+
## Pivot Table
|
|
4078
|
+
|
|
4079
|
+
Visual demonstration for Pivot Table.
|
|
4080
|
+
|
|
4081
|
+
### Rendered Output (LibreOffice Calc)
|
|
4082
|
+
|
|
4083
|
+
<div><img src="../../test/visual/baselines/pivot_table/page-1.png" width="100%" alt="Preview"/></div>
|
|
4084
|
+
|
|
4085
|
+
<div><img src="../../test/visual/baselines/pivot_table/page-2.png" width="100%" alt="Preview"/></div>
|
|
4086
|
+
|
|
4087
|
+
### DSL Code
|
|
4088
|
+
|
|
4089
|
+
```ruby
|
|
4090
|
+
# frozen_string_literal: true
|
|
4091
|
+
|
|
4092
|
+
require "xlsxrb"
|
|
4093
|
+
|
|
4094
|
+
output_path = ARGV[0] || "pivot_table.xlsx"
|
|
4095
|
+
|
|
4096
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4097
|
+
wb.sheet("SalesData") do |sheet|
|
|
4098
|
+
sheet.column(0..3, width: 18)
|
|
4099
|
+
sheet.row(%w[Region Quarter Sales Rep])
|
|
4100
|
+
sheet.row(["East", "Q1", 1000, "Alice"])
|
|
4101
|
+
sheet.row(["West", "Q1", 1500, "Bob"])
|
|
4102
|
+
sheet.row(["East", "Q2", 1200, "Alice"])
|
|
4103
|
+
sheet.row(["West", "Q2", 1800, "Bob"])
|
|
4104
|
+
sheet.row(["North", "Q1", 800, "Charlie"])
|
|
4105
|
+
sheet.row(["North", "Q2", 950, "Charlie"])
|
|
4106
|
+
|
|
4107
|
+
sheet.pivot_table(
|
|
4108
|
+
"SalesData!A1:D7",
|
|
4109
|
+
row_fields: ["Region"],
|
|
4110
|
+
data_fields: [{ name: "Sales", subtotal: "sum" }],
|
|
4111
|
+
col_fields: ["Quarter"],
|
|
4112
|
+
dest_ref: "F1",
|
|
4113
|
+
name: "RegionalSalesSummary"
|
|
4114
|
+
)
|
|
4115
|
+
end
|
|
4116
|
+
end
|
|
4117
|
+
|
|
4118
|
+
puts "=== Read Validation ==="
|
|
4119
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4120
|
+
sheet = workbook.sheets.first
|
|
4121
|
+
sheet.rows.each do |row|
|
|
4122
|
+
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
4123
|
+
puts "Row #{row.index}: #{row_cells.join(", ")}"
|
|
4124
|
+
end
|
|
4125
|
+
```
|
|
4126
|
+
|
|
4127
|
+
### Console Output
|
|
4128
|
+
|
|
4129
|
+
```text
|
|
4130
|
+
=== Read Validation ===
|
|
4131
|
+
Row 0: A1: "Region", B1: "Quarter", C1: "Sales", D1: "Rep"
|
|
4132
|
+
Row 1: A2: "East", B2: "Q1", C2: 1000, D2: "Alice"
|
|
4133
|
+
Row 2: A3: "West", B3: "Q1", C3: 1500, D3: "Bob"
|
|
4134
|
+
Row 3: A4: "East", B4: "Q2", C4: 1200, D4: "Alice"
|
|
4135
|
+
Row 4: A5: "West", B5: "Q2", C5: 1800, D5: "Bob"
|
|
4136
|
+
Row 5: A6: "North", B6: "Q1", C6: 800, D6: "Charlie"
|
|
4137
|
+
Row 6: A7: "North", B7: "Q2", C7: 950, D7: "Charlie"
|
|
4138
|
+
```
|
|
4139
|
+
|
|
4140
|
+
<hr/>
|
|
4141
|
+
|
|
4013
4142
|
## Row Grouping
|
|
4014
4143
|
|
|
4015
4144
|
Demonstrates outline grouping for rows.
|
|
@@ -4357,6 +4486,60 @@ Row 1: A2: "Normal Text" (font=, fill=), B2: "Highlighted Text" (font=Calibri, f
|
|
|
4357
4486
|
|
|
4358
4487
|
<hr/>
|
|
4359
4488
|
|
|
4489
|
+
## Table Styles
|
|
4490
|
+
|
|
4491
|
+
Visual demonstration for Table Styles.
|
|
4492
|
+
|
|
4493
|
+
### Rendered Output (LibreOffice Calc)
|
|
4494
|
+
|
|
4495
|
+
<div><img src="../../test/visual/baselines/table_styles/page-1.png" width="100%" alt="Preview"/></div>
|
|
4496
|
+
|
|
4497
|
+
<div><img src="../../test/visual/baselines/table_styles/page-2.png" width="100%" alt="Preview"/></div>
|
|
4498
|
+
|
|
4499
|
+
### DSL Code
|
|
4500
|
+
|
|
4501
|
+
```ruby
|
|
4502
|
+
# frozen_string_literal: true
|
|
4503
|
+
|
|
4504
|
+
require "xlsxrb"
|
|
4505
|
+
|
|
4506
|
+
output_path = ARGV[0] || "table_styles.xlsx"
|
|
4507
|
+
|
|
4508
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4509
|
+
wb.sheet("Table Example") do |sheet|
|
|
4510
|
+
sheet.column(0..3, width: 20)
|
|
4511
|
+
sheet.row(%w[ID Name Department Salary])
|
|
4512
|
+
sheet.row([101, "Alice Smith", "Engineering", 120_000])
|
|
4513
|
+
sheet.row([102, "Bob Jones", "Marketing", 95_000])
|
|
4514
|
+
sheet.row([103, "Carol White", "Sales", 110_000])
|
|
4515
|
+
sheet.row([104, "David Brown", "Engineering", 130_000])
|
|
4516
|
+
|
|
4517
|
+
sheet.table("A1:D5", columns: %w[ID Name Department Salary], name: "EmployeeTable", style: "TableStyleMedium9", total_row: false)
|
|
4518
|
+
end
|
|
4519
|
+
end
|
|
4520
|
+
|
|
4521
|
+
puts "=== Read Validation ==="
|
|
4522
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4523
|
+
sheet = workbook.sheets.first
|
|
4524
|
+
sheet.rows.each do |row|
|
|
4525
|
+
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
4526
|
+
puts "Row #{row.index}: #{row_cells.join(", ")}"
|
|
4527
|
+
end
|
|
4528
|
+
```
|
|
4529
|
+
|
|
4530
|
+
### Console Output
|
|
4531
|
+
|
|
4532
|
+
```text
|
|
4533
|
+
=== Read Validation ===
|
|
4534
|
+
Row 0: A1: "ID", B1: "Name", C1: "Department", D1: "Salary"
|
|
4535
|
+
Row 1: A2: 101, B2: "Alice Smith", C2: "Engineering", D2: 120000
|
|
4536
|
+
Row 2: A3: 102, B3: "Bob Jones", C3: "Marketing", D3: 95000
|
|
4537
|
+
Row 3: A4: 103, B4: "Carol White", C4: "Sales", D4: 110000
|
|
4538
|
+
Row 4: A5: 104, B5: "David Brown", C5: "Engineering", D5: 130000
|
|
4539
|
+
```
|
|
4540
|
+
|
|
4541
|
+
<hr/>
|
|
4542
|
+
|
|
4360
4543
|
## View Show Grid Lines
|
|
4361
4544
|
|
|
4362
4545
|
Demonstrates disabling visible grid lines in spreadsheet view.
|
data/docs/wasm/ruby.wasm
CHANGED
|
Binary file
|