xlsxrb 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +110 -43
- data/Rakefile +16 -5
- data/Steepfile +1 -0
- data/benchmark.rb +32 -4
- data/docs/ARCHITECTURE.md +32 -30
- data/docs/visual/VisualGallery.md +165 -157
- data/docs/wasm/ruby.wasm +0 -0
- data/lib/ruby_lsp/xlsxrb/addon.rb +43 -0
- data/lib/ruby_lsp/xlsxrb/completion_listener.rb +767 -0
- data/lib/xlsxrb/elements/cell.rb +98 -4
- data/lib/xlsxrb/elements/column.rb +22 -0
- data/lib/xlsxrb/elements/coordinate_access.rb +101 -0
- data/lib/xlsxrb/elements/row.rb +81 -1
- data/lib/xlsxrb/elements/types.rb +36 -5
- data/lib/xlsxrb/elements/workbook.rb +92 -6
- data/lib/xlsxrb/elements/worksheet.rb +138 -59
- data/lib/xlsxrb/elements.rb +1 -0
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +21 -15
- data/lib/xlsxrb/stream_row.rb +181 -0
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb.rb +654 -247
- data/sig/generated/xlsxrb/elements/cell.rbs +10 -1
- data/sig/generated/xlsxrb/elements/column.rbs +5 -0
- data/sig/generated/xlsxrb/elements/coordinate_access.rbs +70 -0
- data/sig/generated/xlsxrb/elements/row.rbs +8 -1
- data/sig/generated/xlsxrb/elements/types.rbs +13 -5
- data/sig/generated/xlsxrb/elements/workbook.rbs +8 -1
- data/sig/generated/xlsxrb/elements/worksheet.rbs +121 -12
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +2 -0
- data/sig/generated/xlsxrb/stream_row.rbs +125 -0
- data/sig/generated/xlsxrb.rbs +674 -262
- metadata +7 -1
|
@@ -431,7 +431,7 @@ Demonstrates horizontal text alignment (left, center, right).
|
|
|
431
431
|
|
|
432
432
|
require "xlsxrb"
|
|
433
433
|
output_path = ARGV[0] || "align_horizontal.xlsx"
|
|
434
|
-
Xlsxrb.
|
|
434
|
+
Xlsxrb.write(output_path) do |wb|
|
|
435
435
|
wb.style("left") { |s| s.align_horizontal("left") }
|
|
436
436
|
wb.style("center") { |s| s.align_horizontal("center") }
|
|
437
437
|
wb.style("right") { |s| s.align_horizontal("right") }
|
|
@@ -446,7 +446,7 @@ end
|
|
|
446
446
|
|
|
447
447
|
# 2. Read the generated sheet and print the parsed alignments
|
|
448
448
|
puts "=== Read Alignment (Xlsxrb.read) ==="
|
|
449
|
-
workbook = Xlsxrb.read(output_path)
|
|
449
|
+
workbook = Xlsxrb.read(output_path).load
|
|
450
450
|
sheet = workbook.sheets.first
|
|
451
451
|
row = sheet.rows.first
|
|
452
452
|
|
|
@@ -483,7 +483,7 @@ Demonstrates horizontal fill alignment (repeats value to fill cell width).
|
|
|
483
483
|
|
|
484
484
|
require "xlsxrb"
|
|
485
485
|
output_path = ARGV[0] || "align_horizontal_fill.xlsx"
|
|
486
|
-
Xlsxrb.
|
|
486
|
+
Xlsxrb.write(output_path) do |wb|
|
|
487
487
|
wb.style("fill_align") { |s| s.align_horizontal("fill") }
|
|
488
488
|
wb.sheet("Alignment") do |s|
|
|
489
489
|
s.column(0, width: 30)
|
|
@@ -493,7 +493,7 @@ end
|
|
|
493
493
|
|
|
494
494
|
# 2. Read the generated sheet and print the parsed alignments
|
|
495
495
|
puts "=== Read Validation ==="
|
|
496
|
-
workbook = Xlsxrb.read(output_path)
|
|
496
|
+
workbook = Xlsxrb.read(output_path).load
|
|
497
497
|
sheet = workbook.sheets.first
|
|
498
498
|
row = sheet.rows.first
|
|
499
499
|
row.cells.each do |c|
|
|
@@ -532,7 +532,7 @@ Demonstrates horizontal justify text alignment.
|
|
|
532
532
|
|
|
533
533
|
require "xlsxrb"
|
|
534
534
|
output_path = ARGV[0] || "align_horizontal_justify.xlsx"
|
|
535
|
-
Xlsxrb.
|
|
535
|
+
Xlsxrb.write(output_path) do |wb|
|
|
536
536
|
wb.style("justify_align") do |s|
|
|
537
537
|
s.align_horizontal("justify")
|
|
538
538
|
s.wrap_text(true)
|
|
@@ -545,7 +545,7 @@ end
|
|
|
545
545
|
|
|
546
546
|
# 2. Read the generated sheet and print the parsed alignments
|
|
547
547
|
puts "=== Read Validation ==="
|
|
548
|
-
workbook = Xlsxrb.read(output_path)
|
|
548
|
+
workbook = Xlsxrb.read(output_path).load
|
|
549
549
|
sheet = workbook.sheets.first
|
|
550
550
|
row = sheet.rows.first
|
|
551
551
|
row.cells.each do |c|
|
|
@@ -584,7 +584,7 @@ Demonstrates text indentation inside cells.
|
|
|
584
584
|
|
|
585
585
|
require "xlsxrb"
|
|
586
586
|
output_path = ARGV[0] || "align_indent.xlsx"
|
|
587
|
-
Xlsxrb.
|
|
587
|
+
Xlsxrb.write(output_path) do |wb|
|
|
588
588
|
wb.style("indent_1") { |s| s.align_horizontal("left").indent(1) }
|
|
589
589
|
wb.style("indent_3") { |s| s.align_horizontal("left").indent(3) }
|
|
590
590
|
wb.sheet("Indent") do |s|
|
|
@@ -599,7 +599,7 @@ end
|
|
|
599
599
|
|
|
600
600
|
# 2. Read the generated sheet and print the parsed alignments
|
|
601
601
|
puts "=== Read Validation ==="
|
|
602
|
-
workbook = Xlsxrb.read(output_path)
|
|
602
|
+
workbook = Xlsxrb.read(output_path).load
|
|
603
603
|
sheet = workbook.sheets.first
|
|
604
604
|
row = sheet.rows.first
|
|
605
605
|
row.cells.each do |c|
|
|
@@ -638,7 +638,7 @@ Demonstrates text rotated by specific angles (45, 90 degrees).
|
|
|
638
638
|
|
|
639
639
|
require "xlsxrb"
|
|
640
640
|
output_path = ARGV[0] || "align_text_rotation.xlsx"
|
|
641
|
-
Xlsxrb.
|
|
641
|
+
Xlsxrb.write(output_path) do |wb|
|
|
642
642
|
wb.style("rot_45") { |s| s.text_rotation(45) }
|
|
643
643
|
wb.style("rot_90") { |s| s.text_rotation(90) }
|
|
644
644
|
wb.sheet("Rotation") do |s|
|
|
@@ -651,7 +651,7 @@ end
|
|
|
651
651
|
|
|
652
652
|
# 2. Read the generated sheet and print the parsed alignments
|
|
653
653
|
puts "=== Read Validation ==="
|
|
654
|
-
workbook = Xlsxrb.read(output_path)
|
|
654
|
+
workbook = Xlsxrb.read(output_path).load
|
|
655
655
|
sheet = workbook.sheets.first
|
|
656
656
|
row = sheet.rows.first
|
|
657
657
|
row.cells.each do |c|
|
|
@@ -691,7 +691,7 @@ Demonstrates auto-wrapping multi-line text inside narrow cells.
|
|
|
691
691
|
|
|
692
692
|
require "xlsxrb"
|
|
693
693
|
output_path = ARGV[0] || "align_text_wrap.xlsx"
|
|
694
|
-
Xlsxrb.
|
|
694
|
+
Xlsxrb.write(output_path) do |wb|
|
|
695
695
|
wb.style("wrap", &:wrap_text)
|
|
696
696
|
wb.sheet("Text Wrap") do |s|
|
|
697
697
|
s.print_options(:grid_lines, true)
|
|
@@ -702,7 +702,7 @@ end
|
|
|
702
702
|
|
|
703
703
|
# 2. Read the generated sheet and print the parsed alignments
|
|
704
704
|
puts "=== Read Validation ==="
|
|
705
|
-
workbook = Xlsxrb.read(output_path)
|
|
705
|
+
workbook = Xlsxrb.read(output_path).load
|
|
706
706
|
sheet = workbook.sheets.first
|
|
707
707
|
row = sheet.rows.first
|
|
708
708
|
row.cells.each do |c|
|
|
@@ -741,7 +741,7 @@ Demonstrates vertical text alignment (top, center, bottom).
|
|
|
741
741
|
|
|
742
742
|
require "xlsxrb"
|
|
743
743
|
output_path = ARGV[0] || "align_vertical.xlsx"
|
|
744
|
-
Xlsxrb.
|
|
744
|
+
Xlsxrb.write(output_path) do |wb|
|
|
745
745
|
wb.style("top") { |s| s.align_vertical("top") }
|
|
746
746
|
wb.style("center") { |s| s.align_vertical("center") }
|
|
747
747
|
wb.style("bottom") { |s| s.align_vertical("bottom") }
|
|
@@ -755,7 +755,7 @@ end
|
|
|
755
755
|
|
|
756
756
|
# 2. Read the generated sheet and print the parsed alignments
|
|
757
757
|
puts "=== Read Validation ==="
|
|
758
|
-
workbook = Xlsxrb.read(output_path)
|
|
758
|
+
workbook = Xlsxrb.read(output_path).load
|
|
759
759
|
sheet = workbook.sheets.first
|
|
760
760
|
row = sheet.rows.first
|
|
761
761
|
row.cells.each do |c|
|
|
@@ -799,7 +799,7 @@ require "date"
|
|
|
799
799
|
|
|
800
800
|
output_path = ARGV[0] || "basic_data.xlsx"
|
|
801
801
|
|
|
802
|
-
Xlsxrb.
|
|
802
|
+
Xlsxrb.write(output_path) do |wb|
|
|
803
803
|
wb.style("currency") { |style| style.number_format("$#,##0.00") }
|
|
804
804
|
wb.style("date") { |style| style.number_format("yyyy-mm-dd") }
|
|
805
805
|
wb.sheet("Basic Data") do |sheet|
|
|
@@ -815,7 +815,7 @@ end
|
|
|
815
815
|
|
|
816
816
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
817
817
|
puts "=== Read Validation ==="
|
|
818
|
-
workbook = Xlsxrb.read(output_path)
|
|
818
|
+
workbook = Xlsxrb.read(output_path).load
|
|
819
819
|
sheet = workbook.sheets.first
|
|
820
820
|
sheet.rows.each do |row|
|
|
821
821
|
row_cells = row.cells.map do |c|
|
|
@@ -853,7 +853,7 @@ require "xlsxrb"
|
|
|
853
853
|
|
|
854
854
|
output_path = ARGV[0] || "borders.xlsx"
|
|
855
855
|
|
|
856
|
-
Xlsxrb.
|
|
856
|
+
Xlsxrb.write(output_path) do |wb|
|
|
857
857
|
wb.style("thin") { |s| s.border_all(style: "thin", color: "FF000000") }
|
|
858
858
|
wb.style("medium") { |s| s.border_all(style: "medium", color: "FF000000") }
|
|
859
859
|
wb.style("thick") { |s| s.border_all(style: "thick", color: "FF000000") }
|
|
@@ -892,7 +892,7 @@ end
|
|
|
892
892
|
|
|
893
893
|
# Read check
|
|
894
894
|
puts "=== Read Validation ==="
|
|
895
|
-
workbook = Xlsxrb.read(output_path)
|
|
895
|
+
workbook = Xlsxrb.read(output_path).load
|
|
896
896
|
sheet = workbook.sheets.first
|
|
897
897
|
sheet.rows.each do |row|
|
|
898
898
|
row_cells = row.cells.map do |c|
|
|
@@ -941,7 +941,7 @@ Demonstrates boolean values serialized and rendered.
|
|
|
941
941
|
|
|
942
942
|
require "xlsxrb"
|
|
943
943
|
output_path = ARGV[0] || "cell_booleans.xlsx"
|
|
944
|
-
Xlsxrb.
|
|
944
|
+
Xlsxrb.write(output_path) do |wb|
|
|
945
945
|
wb.sheet("Booleans") do |s|
|
|
946
946
|
s.column(0, width: 25)
|
|
947
947
|
s.column(1, width: 25)
|
|
@@ -953,7 +953,7 @@ end
|
|
|
953
953
|
|
|
954
954
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
955
955
|
puts "=== Read Validation ==="
|
|
956
|
-
workbook = Xlsxrb.read(output_path)
|
|
956
|
+
workbook = Xlsxrb.read(output_path).load
|
|
957
957
|
sheet = workbook.sheets.first
|
|
958
958
|
sheet.rows.each do |row|
|
|
959
959
|
row_cells = row.cells.map do |c|
|
|
@@ -990,7 +990,7 @@ Demonstrates dates serialized natively and formatted with standard or custom for
|
|
|
990
990
|
require "xlsxrb"
|
|
991
991
|
require "date"
|
|
992
992
|
output_path = ARGV[0] || "cell_dates.xlsx"
|
|
993
|
-
Xlsxrb.
|
|
993
|
+
Xlsxrb.write(output_path) do |wb|
|
|
994
994
|
wb.style("custom_date") { |s| s.num_fmt("yyyy-mm-dd") }
|
|
995
995
|
wb.sheet("Dates") do |s|
|
|
996
996
|
s.column(0, width: 25)
|
|
@@ -1003,7 +1003,7 @@ end
|
|
|
1003
1003
|
|
|
1004
1004
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
1005
1005
|
puts "=== Read Validation ==="
|
|
1006
|
-
workbook = Xlsxrb.read(output_path)
|
|
1006
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1007
1007
|
sheet = workbook.sheets.first
|
|
1008
1008
|
sheet.rows.each do |row|
|
|
1009
1009
|
row_cells = row.cells.map do |c|
|
|
@@ -1039,7 +1039,7 @@ Demonstrates standard spreadsheet calculations and formulas (SUM, AVERAGE).
|
|
|
1039
1039
|
|
|
1040
1040
|
require "xlsxrb"
|
|
1041
1041
|
output_path = ARGV[0] || "cell_formulas.xlsx"
|
|
1042
|
-
Xlsxrb.
|
|
1042
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1043
1043
|
wb.sheet("Formulas") do |s|
|
|
1044
1044
|
s.column(0, width: 25)
|
|
1045
1045
|
s.column(1, width: 25)
|
|
@@ -1053,7 +1053,7 @@ end
|
|
|
1053
1053
|
|
|
1054
1054
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
1055
1055
|
puts "=== Read Validation ==="
|
|
1056
|
-
workbook = Xlsxrb.read(output_path)
|
|
1056
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1057
1057
|
sheet = workbook.sheets.first
|
|
1058
1058
|
sheet.rows.each do |row|
|
|
1059
1059
|
row_cells = row.cells.map do |c|
|
|
@@ -1091,7 +1091,7 @@ Demonstrates Yen Currency format code formatting.
|
|
|
1091
1091
|
|
|
1092
1092
|
require "xlsxrb"
|
|
1093
1093
|
output_path = ARGV[0] || "cell_num_currency_jpy.xlsx"
|
|
1094
|
-
Xlsxrb.
|
|
1094
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1095
1095
|
wb.style("jpy") { |s| s.num_fmt("¥#,##0;[Red]¥-#,##0") }
|
|
1096
1096
|
wb.sheet("JPY Currency") do |s|
|
|
1097
1097
|
s.column(0, width: 25)
|
|
@@ -1104,7 +1104,7 @@ end
|
|
|
1104
1104
|
|
|
1105
1105
|
# 2. Read the generated sheet and print parsed cell numbers and format codes
|
|
1106
1106
|
puts "=== Read Validation ==="
|
|
1107
|
-
workbook = Xlsxrb.read(output_path)
|
|
1107
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1108
1108
|
sheet = workbook.sheets.first
|
|
1109
1109
|
sheet.rows.each do |row|
|
|
1110
1110
|
row_cells = row.cells.map do |c|
|
|
@@ -1142,7 +1142,7 @@ Demonstrates custom colored formats for positive and negative numbers.
|
|
|
1142
1142
|
|
|
1143
1143
|
require "xlsxrb"
|
|
1144
1144
|
output_path = ARGV[0] || "cell_num_custom_colors.xlsx"
|
|
1145
|
-
Xlsxrb.
|
|
1145
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1146
1146
|
wb.style("custom_color") { |s| s.num_fmt("[Green]#,##0;[Red]-#,##0") }
|
|
1147
1147
|
wb.sheet("Custom Colors") do |s|
|
|
1148
1148
|
s.column(0, width: 25)
|
|
@@ -1155,7 +1155,7 @@ end
|
|
|
1155
1155
|
|
|
1156
1156
|
# 2. Read the generated sheet and print parsed cell numbers and format codes
|
|
1157
1157
|
puts "=== Read Validation ==="
|
|
1158
|
-
workbook = Xlsxrb.read(output_path)
|
|
1158
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1159
1159
|
sheet = workbook.sheets.first
|
|
1160
1160
|
sheet.rows.each do |row|
|
|
1161
1161
|
row_cells = row.cells.map do |c|
|
|
@@ -1193,7 +1193,7 @@ Demonstrates fraction number formats (# ?/?).
|
|
|
1193
1193
|
|
|
1194
1194
|
require "xlsxrb"
|
|
1195
1195
|
output_path = ARGV[0] || "cell_num_fractions.xlsx"
|
|
1196
|
-
Xlsxrb.
|
|
1196
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1197
1197
|
wb.style("frac") { |s| s.num_fmt("# ?/?") }
|
|
1198
1198
|
wb.sheet("Fractions") do |s|
|
|
1199
1199
|
s.column(0, width: 25)
|
|
@@ -1207,7 +1207,7 @@ end
|
|
|
1207
1207
|
|
|
1208
1208
|
# 2. Read the generated sheet and print parsed cell numbers and format codes
|
|
1209
1209
|
puts "=== Read Validation ==="
|
|
1210
|
-
workbook = Xlsxrb.read(output_path)
|
|
1210
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1211
1211
|
sheet = workbook.sheets.first
|
|
1212
1212
|
sheet.rows.each do |row|
|
|
1213
1213
|
row_cells = row.cells.map do |c|
|
|
@@ -1246,7 +1246,7 @@ Demonstrates percentages with two decimal places (0.00%).
|
|
|
1246
1246
|
|
|
1247
1247
|
require "xlsxrb"
|
|
1248
1248
|
output_path = ARGV[0] || "cell_num_percent_decimals.xlsx"
|
|
1249
|
-
Xlsxrb.
|
|
1249
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1250
1250
|
wb.style("pct2") { |s| s.num_fmt("0.00%") }
|
|
1251
1251
|
wb.sheet("Percents") do |s|
|
|
1252
1252
|
s.column(0, width: 25)
|
|
@@ -1258,7 +1258,7 @@ end
|
|
|
1258
1258
|
|
|
1259
1259
|
# 2. Read the generated sheet and print parsed cell numbers and format codes
|
|
1260
1260
|
puts "=== Read Validation ==="
|
|
1261
|
-
workbook = Xlsxrb.read(output_path)
|
|
1261
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1262
1262
|
sheet = workbook.sheets.first
|
|
1263
1263
|
sheet.rows.each do |row|
|
|
1264
1264
|
row_cells = row.cells.map do |c|
|
|
@@ -1295,7 +1295,7 @@ Demonstrates scientific number formats (0.00E+00).
|
|
|
1295
1295
|
|
|
1296
1296
|
require "xlsxrb"
|
|
1297
1297
|
output_path = ARGV[0] || "cell_num_scientific.xlsx"
|
|
1298
|
-
Xlsxrb.
|
|
1298
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1299
1299
|
wb.style("sci") { |s| s.num_fmt("0.00E+00") }
|
|
1300
1300
|
wb.sheet("Scientific") do |s|
|
|
1301
1301
|
s.column(0, width: 25)
|
|
@@ -1308,7 +1308,7 @@ end
|
|
|
1308
1308
|
|
|
1309
1309
|
# 2. Read the generated sheet and print parsed cell numbers and format codes
|
|
1310
1310
|
puts "=== Read Validation ==="
|
|
1311
|
-
workbook = Xlsxrb.read(output_path)
|
|
1311
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1312
1312
|
sheet = workbook.sheets.first
|
|
1313
1313
|
sheet.rows.each do |row|
|
|
1314
1314
|
row_cells = row.cells.map do |c|
|
|
@@ -1346,7 +1346,7 @@ Demonstrates custom formatting for integers, floating point numbers, currencies,
|
|
|
1346
1346
|
|
|
1347
1347
|
require "xlsxrb"
|
|
1348
1348
|
output_path = ARGV[0] || "cell_numbers.xlsx"
|
|
1349
|
-
Xlsxrb.
|
|
1349
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1350
1350
|
wb.style("currency") { |s| s.num_fmt("$#,##0.00") }
|
|
1351
1351
|
wb.style("percent") { |s| s.num_fmt("0.0%") }
|
|
1352
1352
|
wb.sheet("Numbers") do |s|
|
|
@@ -1362,7 +1362,7 @@ end
|
|
|
1362
1362
|
|
|
1363
1363
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
1364
1364
|
puts "=== Read Validation ==="
|
|
1365
|
-
workbook = Xlsxrb.read(output_path)
|
|
1365
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1366
1366
|
sheet = workbook.sheets.first
|
|
1367
1367
|
sheet.rows.each do |row|
|
|
1368
1368
|
row_cells = row.cells.map do |c|
|
|
@@ -1400,7 +1400,7 @@ Demonstrates Rich Text cells with multiple font weights, styles, and colors in a
|
|
|
1400
1400
|
|
|
1401
1401
|
require "xlsxrb"
|
|
1402
1402
|
output_path = ARGV[0] || "cell_rich_text.xlsx"
|
|
1403
|
-
Xlsxrb.
|
|
1403
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1404
1404
|
rt = Xlsxrb.rich_text(
|
|
1405
1405
|
{ text: "Normal " },
|
|
1406
1406
|
{ text: "BOLD RED ", font: { bold: true, color: "FFC00000", sz: 16 } },
|
|
@@ -1416,7 +1416,7 @@ end
|
|
|
1416
1416
|
|
|
1417
1417
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
1418
1418
|
puts "=== Read Validation ==="
|
|
1419
|
-
workbook = Xlsxrb.read(output_path)
|
|
1419
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1420
1420
|
sheet = workbook.sheets.first
|
|
1421
1421
|
sheet.rows.each do |row|
|
|
1422
1422
|
row_cells = row.cells.map do |c|
|
|
@@ -1426,6 +1426,14 @@ sheet.rows.each do |row|
|
|
|
1426
1426
|
end
|
|
1427
1427
|
```
|
|
1428
1428
|
|
|
1429
|
+
### Console Output
|
|
1430
|
+
|
|
1431
|
+
```text
|
|
1432
|
+
=== Read Validation ===
|
|
1433
|
+
Row 0: A1: "Format" (String), B1: "Value" (String)
|
|
1434
|
+
Row 1: A2: "Rich Text Cell" (String), B2: "Normal BOLD RED ITALIC BLUE" (String)
|
|
1435
|
+
```
|
|
1436
|
+
|
|
1429
1437
|
<hr/>
|
|
1430
1438
|
|
|
1431
1439
|
## Cell Times
|
|
@@ -1444,7 +1452,7 @@ Demonstrates timestamp values serialized natively and formatted showing hours, m
|
|
|
1444
1452
|
require "xlsxrb"
|
|
1445
1453
|
require "time"
|
|
1446
1454
|
output_path = ARGV[0] || "cell_times.xlsx"
|
|
1447
|
-
Xlsxrb.
|
|
1455
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1448
1456
|
wb.style("time_fmt") { |s| s.num_fmt("hh:mm:ss") }
|
|
1449
1457
|
wb.sheet("Times") do |s|
|
|
1450
1458
|
s.column(0, width: 25)
|
|
@@ -1457,7 +1465,7 @@ end
|
|
|
1457
1465
|
|
|
1458
1466
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
1459
1467
|
puts "=== Read Validation ==="
|
|
1460
|
-
workbook = Xlsxrb.read(output_path)
|
|
1468
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1461
1469
|
sheet = workbook.sheets.first
|
|
1462
1470
|
sheet.rows.each do |row|
|
|
1463
1471
|
row_cells = row.cells.map do |c|
|
|
@@ -1493,7 +1501,7 @@ Demonstrates conditional formatting highlighting cells starting with specific te
|
|
|
1493
1501
|
|
|
1494
1502
|
require "xlsxrb"
|
|
1495
1503
|
output_path = ARGV[0] || "cf_begins_with.xlsx"
|
|
1496
|
-
Xlsxrb.
|
|
1504
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1497
1505
|
wb.sheet("CF Begins") do |s|
|
|
1498
1506
|
s.column(0, width: 25)
|
|
1499
1507
|
s.column(1, width: 25)
|
|
@@ -1507,7 +1515,7 @@ end
|
|
|
1507
1515
|
|
|
1508
1516
|
# 2. Read the generated sheet and print cell values
|
|
1509
1517
|
puts "=== Read Validation ==="
|
|
1510
|
-
workbook = Xlsxrb.read(output_path)
|
|
1518
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1511
1519
|
sheet = workbook.sheets.first
|
|
1512
1520
|
sheet.rows.first(5).each do |row|
|
|
1513
1521
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1542,7 +1550,7 @@ Demonstrates conditional formatting highlighting cells within a range.
|
|
|
1542
1550
|
|
|
1543
1551
|
require "xlsxrb"
|
|
1544
1552
|
output_path = ARGV[0] || "cf_cell_between.xlsx"
|
|
1545
|
-
Xlsxrb.
|
|
1553
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1546
1554
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1547
1555
|
wb.sheet("CF Between") do |s|
|
|
1548
1556
|
s.column(0, width: 25)
|
|
@@ -1557,7 +1565,7 @@ end
|
|
|
1557
1565
|
|
|
1558
1566
|
# 2. Read the generated sheet and print cell values
|
|
1559
1567
|
puts "=== Read Validation ==="
|
|
1560
|
-
workbook = Xlsxrb.read(output_path)
|
|
1568
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1561
1569
|
sheet = workbook.sheets.first
|
|
1562
1570
|
sheet.rows.first(5).each do |row|
|
|
1563
1571
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1592,7 +1600,7 @@ Demonstrates conditional formatting highlighting cells equal to a target value.
|
|
|
1592
1600
|
|
|
1593
1601
|
require "xlsxrb"
|
|
1594
1602
|
output_path = ARGV[0] || "cf_cell_equal_to.xlsx"
|
|
1595
|
-
Xlsxrb.
|
|
1603
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1596
1604
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1597
1605
|
wb.sheet("CF Equal") do |s|
|
|
1598
1606
|
s.column(0, width: 25)
|
|
@@ -1607,7 +1615,7 @@ end
|
|
|
1607
1615
|
|
|
1608
1616
|
# 2. Read the generated sheet and print cell values
|
|
1609
1617
|
puts "=== Read Validation ==="
|
|
1610
|
-
workbook = Xlsxrb.read(output_path)
|
|
1618
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1611
1619
|
sheet = workbook.sheets.first
|
|
1612
1620
|
sheet.rows.first(5).each do |row|
|
|
1613
1621
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1642,7 +1650,7 @@ Demonstrates conditional formatting highlighting cells greater than or equal to
|
|
|
1642
1650
|
|
|
1643
1651
|
require "xlsxrb"
|
|
1644
1652
|
output_path = ARGV[0] || "cf_cell_greater_equal.xlsx"
|
|
1645
|
-
Xlsxrb.
|
|
1653
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1646
1654
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1647
1655
|
wb.sheet("CF Greater Equal") do |s|
|
|
1648
1656
|
s.column(0, width: 25)
|
|
@@ -1657,7 +1665,7 @@ end
|
|
|
1657
1665
|
|
|
1658
1666
|
# 2. Read the generated sheet and print cell values
|
|
1659
1667
|
puts "=== Read Validation ==="
|
|
1660
|
-
workbook = Xlsxrb.read(output_path)
|
|
1668
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1661
1669
|
sheet = workbook.sheets.first
|
|
1662
1670
|
sheet.rows.first(5).each do |row|
|
|
1663
1671
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1692,7 +1700,7 @@ Demonstrates conditional formatting highlighting cells greater than a threshold.
|
|
|
1692
1700
|
|
|
1693
1701
|
require "xlsxrb"
|
|
1694
1702
|
output_path = ARGV[0] || "cf_cell_greater_than.xlsx"
|
|
1695
|
-
Xlsxrb.
|
|
1703
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1696
1704
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1697
1705
|
wb.sheet("CF Greater") do |s|
|
|
1698
1706
|
s.column(0, width: 25)
|
|
@@ -1707,7 +1715,7 @@ end
|
|
|
1707
1715
|
|
|
1708
1716
|
# 2. Read the generated sheet and print cell values
|
|
1709
1717
|
puts "=== Read Validation ==="
|
|
1710
|
-
workbook = Xlsxrb.read(output_path)
|
|
1718
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1711
1719
|
sheet = workbook.sheets.first
|
|
1712
1720
|
sheet.rows.first(5).each do |row|
|
|
1713
1721
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1742,7 +1750,7 @@ Demonstrates conditional formatting highlighting cells less than a threshold.
|
|
|
1742
1750
|
|
|
1743
1751
|
require "xlsxrb"
|
|
1744
1752
|
output_path = ARGV[0] || "cf_cell_less_than.xlsx"
|
|
1745
|
-
Xlsxrb.
|
|
1753
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1746
1754
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1747
1755
|
wb.sheet("CF Less") do |s|
|
|
1748
1756
|
s.column(0, width: 25)
|
|
@@ -1757,7 +1765,7 @@ end
|
|
|
1757
1765
|
|
|
1758
1766
|
# 2. Read the generated sheet and print cell values
|
|
1759
1767
|
puts "=== Read Validation ==="
|
|
1760
|
-
workbook = Xlsxrb.read(output_path)
|
|
1768
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1761
1769
|
sheet = workbook.sheets.first
|
|
1762
1770
|
sheet.rows.first(5).each do |row|
|
|
1763
1771
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1792,7 +1800,7 @@ Demonstrates color scale/heatmap conditional formatting.
|
|
|
1792
1800
|
|
|
1793
1801
|
require "xlsxrb"
|
|
1794
1802
|
output_path = ARGV[0] || "cf_color_scale.xlsx"
|
|
1795
|
-
Xlsxrb.
|
|
1803
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1796
1804
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1797
1805
|
wb.sheet("Colors") do |s|
|
|
1798
1806
|
s.column(0, width: 25)
|
|
@@ -1806,7 +1814,7 @@ end
|
|
|
1806
1814
|
|
|
1807
1815
|
# 2. Read the generated sheet and print cell values
|
|
1808
1816
|
puts "=== Read Validation ==="
|
|
1809
|
-
workbook = Xlsxrb.read(output_path)
|
|
1817
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1810
1818
|
sheet = workbook.sheets.first
|
|
1811
1819
|
sheet.rows.first(5).each do |row|
|
|
1812
1820
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1840,7 +1848,7 @@ Demonstrates conditional formatting highlighting cells containing specific text.
|
|
|
1840
1848
|
|
|
1841
1849
|
require "xlsxrb"
|
|
1842
1850
|
output_path = ARGV[0] || "cf_contains_text.xlsx"
|
|
1843
|
-
Xlsxrb.
|
|
1851
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1844
1852
|
wb.sheet("CF Contains") do |s|
|
|
1845
1853
|
s.column(0, width: 25)
|
|
1846
1854
|
s.column(1, width: 25)
|
|
@@ -1854,7 +1862,7 @@ end
|
|
|
1854
1862
|
|
|
1855
1863
|
# 2. Read the generated sheet and print cell values
|
|
1856
1864
|
puts "=== Read Validation ==="
|
|
1857
|
-
workbook = Xlsxrb.read(output_path)
|
|
1865
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1858
1866
|
sheet = workbook.sheets.first
|
|
1859
1867
|
sheet.rows.first(5).each do |row|
|
|
1860
1868
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1889,7 +1897,7 @@ Demonstrates data bar visual conditional formatting indicators.
|
|
|
1889
1897
|
|
|
1890
1898
|
require "xlsxrb"
|
|
1891
1899
|
output_path = ARGV[0] || "cf_data_bar.xlsx"
|
|
1892
|
-
Xlsxrb.
|
|
1900
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1893
1901
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1894
1902
|
wb.sheet("Data Bars") do |s|
|
|
1895
1903
|
s.column(0, width: 25)
|
|
@@ -1903,7 +1911,7 @@ end
|
|
|
1903
1911
|
|
|
1904
1912
|
# 2. Read the generated sheet and print cell values
|
|
1905
1913
|
puts "=== Read Validation ==="
|
|
1906
|
-
workbook = Xlsxrb.read(output_path)
|
|
1914
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1907
1915
|
sheet = workbook.sheets.first
|
|
1908
1916
|
sheet.rows.first(5).each do |row|
|
|
1909
1917
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1937,7 +1945,7 @@ Demonstrates conditional formatting highlighting cells ending with specific text
|
|
|
1937
1945
|
|
|
1938
1946
|
require "xlsxrb"
|
|
1939
1947
|
output_path = ARGV[0] || "cf_ends_with.xlsx"
|
|
1940
|
-
Xlsxrb.
|
|
1948
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1941
1949
|
wb.sheet("CF Ends") do |s|
|
|
1942
1950
|
s.column(0, width: 25)
|
|
1943
1951
|
s.column(1, width: 25)
|
|
@@ -1951,7 +1959,7 @@ end
|
|
|
1951
1959
|
|
|
1952
1960
|
# 2. Read the generated sheet and print cell values
|
|
1953
1961
|
puts "=== Read Validation ==="
|
|
1954
|
-
workbook = Xlsxrb.read(output_path)
|
|
1962
|
+
workbook = Xlsxrb.read(output_path).load
|
|
1955
1963
|
sheet = workbook.sheets.first
|
|
1956
1964
|
sheet.rows.first(5).each do |row|
|
|
1957
1965
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -1986,7 +1994,7 @@ Demonstrates conditional formatting using a custom formula expression.
|
|
|
1986
1994
|
|
|
1987
1995
|
require "xlsxrb"
|
|
1988
1996
|
output_path = ARGV[0] || "cf_expression_formula.xlsx"
|
|
1989
|
-
Xlsxrb.
|
|
1997
|
+
Xlsxrb.write(output_path) do |wb|
|
|
1990
1998
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
1991
1999
|
wb.sheet("CF Expression") do |s|
|
|
1992
2000
|
s.column(0, width: 25)
|
|
@@ -2002,7 +2010,7 @@ end
|
|
|
2002
2010
|
|
|
2003
2011
|
# 2. Read the generated sheet and print cell values
|
|
2004
2012
|
puts "=== Read Validation ==="
|
|
2005
|
-
workbook = Xlsxrb.read(output_path)
|
|
2013
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2006
2014
|
sheet = workbook.sheets.first
|
|
2007
2015
|
sheet.rows.first(5).each do |row|
|
|
2008
2016
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -2038,7 +2046,7 @@ Demonstrates icon set indicators (red/yellow/green arrows).
|
|
|
2038
2046
|
|
|
2039
2047
|
require "xlsxrb"
|
|
2040
2048
|
output_path = ARGV[0] || "cf_icon_set.xlsx"
|
|
2041
|
-
Xlsxrb.
|
|
2049
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2042
2050
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
2043
2051
|
wb.sheet("Icons") do |s|
|
|
2044
2052
|
s.column(0, width: 25)
|
|
@@ -2052,7 +2060,7 @@ end
|
|
|
2052
2060
|
|
|
2053
2061
|
# 2. Read the generated sheet and print cell values
|
|
2054
2062
|
puts "=== Read Validation ==="
|
|
2055
|
-
workbook = Xlsxrb.read(output_path)
|
|
2063
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2056
2064
|
sheet = workbook.sheets.first
|
|
2057
2065
|
sheet.rows.first(5).each do |row|
|
|
2058
2066
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -2086,7 +2094,7 @@ Demonstrates embedding a standard 2D Area Chart.
|
|
|
2086
2094
|
|
|
2087
2095
|
require "xlsxrb"
|
|
2088
2096
|
output_path = ARGV[0] || "chart_area.xlsx"
|
|
2089
|
-
Xlsxrb.
|
|
2097
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2090
2098
|
wb.sheet("Data") do |s|
|
|
2091
2099
|
s.sheet_properties(:fit_to_page, true)
|
|
2092
2100
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2106,7 +2114,7 @@ end
|
|
|
2106
2114
|
|
|
2107
2115
|
# 2. Read the generated sheet and print the chart count
|
|
2108
2116
|
puts "=== Read Validation ==="
|
|
2109
|
-
workbook = Xlsxrb.read(output_path)
|
|
2117
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2110
2118
|
sheet = workbook.sheets.first
|
|
2111
2119
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2112
2120
|
```
|
|
@@ -2135,7 +2143,7 @@ Demonstrates embedding a stacked 2D Area Chart.
|
|
|
2135
2143
|
|
|
2136
2144
|
require "xlsxrb"
|
|
2137
2145
|
output_path = ARGV[0] || "chart_area_stacked.xlsx"
|
|
2138
|
-
Xlsxrb.
|
|
2146
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2139
2147
|
wb.sheet("Data") do |s|
|
|
2140
2148
|
s.column(0, width: 25)
|
|
2141
2149
|
s.column(1, width: 25)
|
|
@@ -2160,7 +2168,7 @@ end
|
|
|
2160
2168
|
|
|
2161
2169
|
# 2. Read the generated sheet and print the chart count
|
|
2162
2170
|
puts "=== Read Validation ==="
|
|
2163
|
-
workbook = Xlsxrb.read(output_path)
|
|
2171
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2164
2172
|
sheet = workbook.sheets.first
|
|
2165
2173
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2166
2174
|
```
|
|
@@ -2191,7 +2199,7 @@ require "xlsxrb"
|
|
|
2191
2199
|
|
|
2192
2200
|
output_path = ARGV[0] || "chart_bar.xlsx"
|
|
2193
2201
|
|
|
2194
|
-
Xlsxrb.
|
|
2202
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2195
2203
|
wb.sheet("Sales Data") do |s|
|
|
2196
2204
|
s.sheet_properties(:fit_to_page, true)
|
|
2197
2205
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2217,7 +2225,7 @@ end
|
|
|
2217
2225
|
|
|
2218
2226
|
# 2. Read the generated sheet and print the chart count
|
|
2219
2227
|
puts "=== Read Validation ==="
|
|
2220
|
-
workbook = Xlsxrb.read(output_path)
|
|
2228
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2221
2229
|
sheet = workbook.sheets.first
|
|
2222
2230
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2223
2231
|
```
|
|
@@ -2246,7 +2254,7 @@ Demonstrates embedding a 100% stacked 2D Bar Chart.
|
|
|
2246
2254
|
|
|
2247
2255
|
require "xlsxrb"
|
|
2248
2256
|
output_path = ARGV[0] || "chart_bar_percent_stacked.xlsx"
|
|
2249
|
-
Xlsxrb.
|
|
2257
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2250
2258
|
wb.sheet("Data") do |s|
|
|
2251
2259
|
s.column(0, width: 25)
|
|
2252
2260
|
s.column(1, width: 25)
|
|
@@ -2271,7 +2279,7 @@ end
|
|
|
2271
2279
|
|
|
2272
2280
|
# 2. Read the generated sheet and print the chart count
|
|
2273
2281
|
puts "=== Read Validation ==="
|
|
2274
|
-
workbook = Xlsxrb.read(output_path)
|
|
2282
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2275
2283
|
sheet = workbook.sheets.first
|
|
2276
2284
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2277
2285
|
```
|
|
@@ -2300,7 +2308,7 @@ Demonstrates embedding a stacked 2D Bar Chart.
|
|
|
2300
2308
|
|
|
2301
2309
|
require "xlsxrb"
|
|
2302
2310
|
output_path = ARGV[0] || "chart_bar_stacked.xlsx"
|
|
2303
|
-
Xlsxrb.
|
|
2311
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2304
2312
|
wb.sheet("Data") do |s|
|
|
2305
2313
|
s.column(0, width: 25)
|
|
2306
2314
|
s.column(1, width: 25)
|
|
@@ -2325,7 +2333,7 @@ end
|
|
|
2325
2333
|
|
|
2326
2334
|
# 2. Read the generated sheet and print the chart count
|
|
2327
2335
|
puts "=== Read Validation ==="
|
|
2328
|
-
workbook = Xlsxrb.read(output_path)
|
|
2336
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2329
2337
|
sheet = workbook.sheets.first
|
|
2330
2338
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2331
2339
|
```
|
|
@@ -2354,7 +2362,7 @@ Demonstrates embedding a standard 2D Doughnut Chart.
|
|
|
2354
2362
|
|
|
2355
2363
|
require "xlsxrb"
|
|
2356
2364
|
output_path = ARGV[0] || "chart_doughnut.xlsx"
|
|
2357
|
-
Xlsxrb.
|
|
2365
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2358
2366
|
wb.sheet("Data") do |s|
|
|
2359
2367
|
s.sheet_properties(:fit_to_page, true)
|
|
2360
2368
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2381,7 +2389,7 @@ end
|
|
|
2381
2389
|
|
|
2382
2390
|
# 2. Read the generated sheet and print the chart count
|
|
2383
2391
|
puts "=== Read Validation ==="
|
|
2384
|
-
workbook = Xlsxrb.read(output_path)
|
|
2392
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2385
2393
|
sheet = workbook.sheets.first
|
|
2386
2394
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2387
2395
|
```
|
|
@@ -2410,7 +2418,7 @@ Demonstrates embedding a standard 2D Line Chart.
|
|
|
2410
2418
|
|
|
2411
2419
|
require "xlsxrb"
|
|
2412
2420
|
output_path = ARGV[0] || "chart_line.xlsx"
|
|
2413
|
-
Xlsxrb.
|
|
2421
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2414
2422
|
wb.sheet("Data") do |s|
|
|
2415
2423
|
s.sheet_properties(:fit_to_page, true)
|
|
2416
2424
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2431,7 +2439,7 @@ end
|
|
|
2431
2439
|
|
|
2432
2440
|
# 2. Read the generated sheet and print the chart count
|
|
2433
2441
|
puts "=== Read Validation ==="
|
|
2434
|
-
workbook = Xlsxrb.read(output_path)
|
|
2442
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2435
2443
|
sheet = workbook.sheets.first
|
|
2436
2444
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2437
2445
|
```
|
|
@@ -2460,7 +2468,7 @@ Demonstrates embedding a stacked 2D Line Chart.
|
|
|
2460
2468
|
|
|
2461
2469
|
require "xlsxrb"
|
|
2462
2470
|
output_path = ARGV[0] || "chart_line_stacked.xlsx"
|
|
2463
|
-
Xlsxrb.
|
|
2471
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2464
2472
|
wb.sheet("Data") do |s|
|
|
2465
2473
|
s.column(0, width: 25)
|
|
2466
2474
|
s.column(1, width: 25)
|
|
@@ -2485,7 +2493,7 @@ end
|
|
|
2485
2493
|
|
|
2486
2494
|
# 2. Read the generated sheet and print the chart count
|
|
2487
2495
|
puts "=== Read Validation ==="
|
|
2488
|
-
workbook = Xlsxrb.read(output_path)
|
|
2496
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2489
2497
|
sheet = workbook.sheets.first
|
|
2490
2498
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2491
2499
|
```
|
|
@@ -2514,7 +2522,7 @@ Demonstrates embedding a standard 2D Pie Chart.
|
|
|
2514
2522
|
|
|
2515
2523
|
require "xlsxrb"
|
|
2516
2524
|
output_path = ARGV[0] || "chart_pie.xlsx"
|
|
2517
|
-
Xlsxrb.
|
|
2525
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2518
2526
|
wb.sheet("Data") do |s|
|
|
2519
2527
|
s.sheet_properties(:fit_to_page, true)
|
|
2520
2528
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2541,7 +2549,7 @@ end
|
|
|
2541
2549
|
|
|
2542
2550
|
# 2. Read the generated sheet and print the chart count
|
|
2543
2551
|
puts "=== Read Validation ==="
|
|
2544
|
-
workbook = Xlsxrb.read(output_path)
|
|
2552
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2545
2553
|
sheet = workbook.sheets.first
|
|
2546
2554
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2547
2555
|
```
|
|
@@ -2570,7 +2578,7 @@ Demonstrates embedding a standard 2D Radar Chart.
|
|
|
2570
2578
|
|
|
2571
2579
|
require "xlsxrb"
|
|
2572
2580
|
output_path = ARGV[0] || "chart_radar.xlsx"
|
|
2573
|
-
Xlsxrb.
|
|
2581
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2574
2582
|
wb.sheet("Data") do |s|
|
|
2575
2583
|
s.sheet_properties(:fit_to_page, true)
|
|
2576
2584
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2590,7 +2598,7 @@ end
|
|
|
2590
2598
|
|
|
2591
2599
|
# 2. Read the generated sheet and print the chart count
|
|
2592
2600
|
puts "=== Read Validation ==="
|
|
2593
|
-
workbook = Xlsxrb.read(output_path)
|
|
2601
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2594
2602
|
sheet = workbook.sheets.first
|
|
2595
2603
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2596
2604
|
```
|
|
@@ -2619,7 +2627,7 @@ Demonstrates embedding a standard 2D Scatter Plot.
|
|
|
2619
2627
|
|
|
2620
2628
|
require "xlsxrb"
|
|
2621
2629
|
output_path = ARGV[0] || "chart_scatter.xlsx"
|
|
2622
|
-
Xlsxrb.
|
|
2630
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2623
2631
|
wb.sheet("Data") do |s|
|
|
2624
2632
|
s.sheet_properties(:fit_to_page, true)
|
|
2625
2633
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -2639,7 +2647,7 @@ end
|
|
|
2639
2647
|
|
|
2640
2648
|
# 2. Read the generated sheet and print the chart count
|
|
2641
2649
|
puts "=== Read Validation ==="
|
|
2642
|
-
workbook = Xlsxrb.read(output_path)
|
|
2650
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2643
2651
|
sheet = workbook.sheets.first
|
|
2644
2652
|
puts "Sheet '#{sheet.name}' has #{sheet.charts.size} chart(s)"
|
|
2645
2653
|
```
|
|
@@ -2668,7 +2676,7 @@ Demonstrates outline grouping for columns.
|
|
|
2668
2676
|
|
|
2669
2677
|
require "xlsxrb"
|
|
2670
2678
|
output_path = ARGV[0] || "col_grouping.xlsx"
|
|
2671
|
-
Xlsxrb.
|
|
2679
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2672
2680
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
2673
2681
|
wb.sheet("Col Grouping") do |s|
|
|
2674
2682
|
s.sheet_properties(:fit_to_page, true)
|
|
@@ -2682,7 +2690,7 @@ end
|
|
|
2682
2690
|
|
|
2683
2691
|
# 2. Read the generated sheet and print column dimensions
|
|
2684
2692
|
puts "=== Read Validation ==="
|
|
2685
|
-
workbook = Xlsxrb.read(output_path)
|
|
2693
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2686
2694
|
sheet = workbook.sheets.first
|
|
2687
2695
|
sheet.columns.each do |col|
|
|
2688
2696
|
puts "Column #{col.index}: width=#{col.width}, hidden=#{col.hidden}, outline_level=#{col.outline_level}"
|
|
@@ -2715,7 +2723,7 @@ Demonstrates setting very wide column widths.
|
|
|
2715
2723
|
|
|
2716
2724
|
require "xlsxrb"
|
|
2717
2725
|
output_path = ARGV[0] || "col_width_tall.xlsx"
|
|
2718
|
-
Xlsxrb.
|
|
2726
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2719
2727
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
2720
2728
|
wb.sheet("Col Width") do |s|
|
|
2721
2729
|
s.column(0, width: 50)
|
|
@@ -2726,7 +2734,7 @@ end
|
|
|
2726
2734
|
|
|
2727
2735
|
# 2. Read the generated sheet and print column dimensions
|
|
2728
2736
|
puts "=== Read Validation ==="
|
|
2729
|
-
workbook = Xlsxrb.read(output_path)
|
|
2737
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2730
2738
|
sheet = workbook.sheets.first
|
|
2731
2739
|
sheet.columns.each do |col|
|
|
2732
2740
|
puts "Column #{col.index}: width=#{col.width}, hidden=#{col.hidden}, outline_level=#{col.outline_level}"
|
|
@@ -2758,7 +2766,7 @@ Demonstrates setting custom column widths.
|
|
|
2758
2766
|
|
|
2759
2767
|
require "xlsxrb"
|
|
2760
2768
|
output_path = ARGV[0] || "col_widths.xlsx"
|
|
2761
|
-
Xlsxrb.
|
|
2769
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2762
2770
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
2763
2771
|
wb.sheet("Widths") do |s|
|
|
2764
2772
|
s.column(0, width: 30)
|
|
@@ -2769,7 +2777,7 @@ end
|
|
|
2769
2777
|
|
|
2770
2778
|
# 2. Read the generated sheet and print column dimensions
|
|
2771
2779
|
puts "=== Read Validation ==="
|
|
2772
|
-
workbook = Xlsxrb.read(output_path)
|
|
2780
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2773
2781
|
sheet = workbook.sheets.first
|
|
2774
2782
|
sheet.columns.each do |col|
|
|
2775
2783
|
puts "Column #{col.index}: width=#{col.width}, hidden=#{col.hidden}, outline_level=#{col.outline_level}"
|
|
@@ -2803,7 +2811,7 @@ require "xlsxrb"
|
|
|
2803
2811
|
|
|
2804
2812
|
output_path = ARGV[0] || "conditional_formatting.xlsx"
|
|
2805
2813
|
|
|
2806
|
-
Xlsxrb.
|
|
2814
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2807
2815
|
wb.style("center") { |style| style.align_horizontal("center") }
|
|
2808
2816
|
wb.sheet("Scores") do |s|
|
|
2809
2817
|
s.column(0, width: 25)
|
|
@@ -2819,7 +2827,7 @@ end
|
|
|
2819
2827
|
|
|
2820
2828
|
# 2. Read the generated sheet and print cell values
|
|
2821
2829
|
puts "=== Read Validation ==="
|
|
2822
|
-
workbook = Xlsxrb.read(output_path)
|
|
2830
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2823
2831
|
sheet = workbook.sheets.first
|
|
2824
2832
|
sheet.rows.first(5).each do |row|
|
|
2825
2833
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -2873,7 +2881,7 @@ end
|
|
|
2873
2881
|
|
|
2874
2882
|
dummy_png = make_png(100, 100, 255, 0, 0)
|
|
2875
2883
|
|
|
2876
|
-
Xlsxrb.
|
|
2884
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2877
2885
|
wb.style("center") { |st| st.align_horizontal(:center) }
|
|
2878
2886
|
wb.sheet("Images") do |s|
|
|
2879
2887
|
s.row(["Logo Target cell:", "", "", "Boundary"], styles: %w[left center center center])
|
|
@@ -2892,7 +2900,7 @@ end
|
|
|
2892
2900
|
# 2. Read the generated sheet and print cell values + parsed embedded images details
|
|
2893
2901
|
puts "=== Read Validation ==="
|
|
2894
2902
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
2895
|
-
workbook = Xlsxrb.read(output_path)
|
|
2903
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2896
2904
|
sheet = workbook.sheets.first
|
|
2897
2905
|
sheet.rows.first(5).each do |row|
|
|
2898
2906
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -2936,7 +2944,7 @@ Demonstrates linear gradients inside cell backgrounds.
|
|
|
2936
2944
|
|
|
2937
2945
|
require "xlsxrb"
|
|
2938
2946
|
output_path = ARGV[0] || "fill_gradients.xlsx"
|
|
2939
|
-
Xlsxrb.
|
|
2947
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2940
2948
|
wb.style("gradient") do |style|
|
|
2941
2949
|
style.fill_gradient(type: "linear", degree: 45, stops: [
|
|
2942
2950
|
{ position: 0, color: "FFFFFFFF" },
|
|
@@ -2952,7 +2960,7 @@ end
|
|
|
2952
2960
|
|
|
2953
2961
|
# 2. Read the generated sheet and print cell fill properties
|
|
2954
2962
|
puts "=== Read Validation ==="
|
|
2955
|
-
workbook = Xlsxrb.read(output_path)
|
|
2963
|
+
workbook = Xlsxrb.read(output_path).load
|
|
2956
2964
|
sheet = workbook.sheets.first
|
|
2957
2965
|
row = sheet.rows.first
|
|
2958
2966
|
row.cells.each do |c|
|
|
@@ -2987,7 +2995,7 @@ Demonstrates standard pattern fills (darkGray, darkGrid) in cell backgrounds.
|
|
|
2987
2995
|
|
|
2988
2996
|
require "xlsxrb"
|
|
2989
2997
|
output_path = ARGV[0] || "fill_patterns.xlsx"
|
|
2990
|
-
Xlsxrb.
|
|
2998
|
+
Xlsxrb.write(output_path) do |wb|
|
|
2991
2999
|
wb.style("dark_gray") { |s| s.fill(pattern: "darkGray", fg_color: "FFC0C0C0", bg_color: "FFFFFFFF") }
|
|
2992
3000
|
wb.style("grid_fill") { |s| s.fill(pattern: "darkGrid", fg_color: "FFC0C0C0", bg_color: "FFFFFFFF") }
|
|
2993
3001
|
wb.sheet("Patterns") do |s|
|
|
@@ -3001,7 +3009,7 @@ end
|
|
|
3001
3009
|
|
|
3002
3010
|
# 2. Read the generated sheet and print cell fill properties
|
|
3003
3011
|
puts "=== Read Validation ==="
|
|
3004
|
-
workbook = Xlsxrb.read(output_path)
|
|
3012
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3005
3013
|
sheet = workbook.sheets.first
|
|
3006
3014
|
row = sheet.rows.first
|
|
3007
3015
|
row.cells.each do |c|
|
|
@@ -3036,7 +3044,7 @@ Demonstrates solid cell background fill colors.
|
|
|
3036
3044
|
|
|
3037
3045
|
require "xlsxrb"
|
|
3038
3046
|
output_path = ARGV[0] || "fill_solid_colors.xlsx"
|
|
3039
|
-
Xlsxrb.
|
|
3047
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3040
3048
|
wb.style("red_fill") { |s| s.fill_color("FFFFC7CE") }
|
|
3041
3049
|
wb.style("green_fill") { |s| s.fill_color("FFC6EFCE") }
|
|
3042
3050
|
wb.sheet("Fills") do |s|
|
|
@@ -3050,7 +3058,7 @@ end
|
|
|
3050
3058
|
|
|
3051
3059
|
# 2. Read the generated sheet and print cell fill properties
|
|
3052
3060
|
puts "=== Read Validation ==="
|
|
3053
|
-
workbook = Xlsxrb.read(output_path)
|
|
3061
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3054
3062
|
sheet = workbook.sheets.first
|
|
3055
3063
|
row = sheet.rows.first
|
|
3056
3064
|
row.cells.each do |c|
|
|
@@ -3087,7 +3095,7 @@ require "xlsxrb"
|
|
|
3087
3095
|
|
|
3088
3096
|
output_path = ARGV[0] || "fonts.xlsx"
|
|
3089
3097
|
|
|
3090
|
-
Xlsxrb.
|
|
3098
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3091
3099
|
# Font Families (using nested hash options)
|
|
3092
3100
|
wb.style("f_arial", font: { name: "Arial" })
|
|
3093
3101
|
wb.style("f_times", font: { name: "Times New Roman" })
|
|
@@ -3180,7 +3188,7 @@ Demonstrates enabling auto-filter sorting headers on tables. Download the sheet
|
|
|
3180
3188
|
|
|
3181
3189
|
require "xlsxrb"
|
|
3182
3190
|
output_path = ARGV[0] || "interactive_autofilter.xlsx"
|
|
3183
|
-
Xlsxrb.
|
|
3191
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3184
3192
|
wb.sheet("Filter") do |s|
|
|
3185
3193
|
s.column(0, width: 25)
|
|
3186
3194
|
s.column(1, width: 25)
|
|
@@ -3194,7 +3202,7 @@ end
|
|
|
3194
3202
|
|
|
3195
3203
|
# 2. Read the generated sheet and print cell values
|
|
3196
3204
|
puts "=== Read Validation ==="
|
|
3197
|
-
workbook = Xlsxrb.read(output_path)
|
|
3205
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3198
3206
|
sheet = workbook.sheets.first
|
|
3199
3207
|
sheet.rows.first(5).each do |row|
|
|
3200
3208
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -3233,7 +3241,7 @@ Demonstrates cell pop-up comments. Open the sheet in Excel and hover your mouse
|
|
|
3233
3241
|
|
|
3234
3242
|
require "xlsxrb"
|
|
3235
3243
|
output_path = ARGV[0] || "interactive_comments.xlsx"
|
|
3236
|
-
Xlsxrb.
|
|
3244
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3237
3245
|
wb.sheet("Comments") do |s|
|
|
3238
3246
|
s.column(0, width: 25)
|
|
3239
3247
|
s.column(1, width: 25)
|
|
@@ -3244,7 +3252,7 @@ end
|
|
|
3244
3252
|
|
|
3245
3253
|
# 2. Read the generated sheet and print cell values
|
|
3246
3254
|
puts "=== Read Validation ==="
|
|
3247
|
-
workbook = Xlsxrb.read(output_path)
|
|
3255
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3248
3256
|
sheet = workbook.sheets.first
|
|
3249
3257
|
sheet.rows.first(5).each do |row|
|
|
3250
3258
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -3281,7 +3289,7 @@ Demonstrates interactive custom formula validation rules.
|
|
|
3281
3289
|
|
|
3282
3290
|
require "xlsxrb"
|
|
3283
3291
|
output_path = ARGV[0] || "interactive_validation_custom.xlsx"
|
|
3284
|
-
Xlsxrb.
|
|
3292
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3285
3293
|
wb.sheet("Custom Rule") do |s|
|
|
3286
3294
|
s.column(0, width: 25)
|
|
3287
3295
|
s.column(1, width: 25)
|
|
@@ -3294,7 +3302,7 @@ end
|
|
|
3294
3302
|
# 2. Read the generated sheet and print data validations
|
|
3295
3303
|
puts "=== Read Validation ==="
|
|
3296
3304
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3297
|
-
workbook = Xlsxrb.read(output_path)
|
|
3305
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3298
3306
|
sheet = workbook.sheets.first
|
|
3299
3307
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3300
3308
|
validations.each do |v|
|
|
@@ -3331,7 +3339,7 @@ Demonstrates interactive date range constraints validation rules.
|
|
|
3331
3339
|
|
|
3332
3340
|
require "xlsxrb"
|
|
3333
3341
|
output_path = ARGV[0] || "interactive_validation_date.xlsx"
|
|
3334
|
-
Xlsxrb.
|
|
3342
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3335
3343
|
wb.sheet("Date Validation") do |s|
|
|
3336
3344
|
s.column(0, width: 25)
|
|
3337
3345
|
s.column(1, width: 25)
|
|
@@ -3343,7 +3351,7 @@ end
|
|
|
3343
3351
|
# 2. Read the generated sheet and print data validations
|
|
3344
3352
|
puts "=== Read Validation ==="
|
|
3345
3353
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3346
|
-
workbook = Xlsxrb.read(output_path)
|
|
3354
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3347
3355
|
sheet = workbook.sheets.first
|
|
3348
3356
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3349
3357
|
validations.each do |v|
|
|
@@ -3380,7 +3388,7 @@ Demonstrates dropdown list data validations. Open the sheet in Excel and select
|
|
|
3380
3388
|
|
|
3381
3389
|
require "xlsxrb"
|
|
3382
3390
|
output_path = ARGV[0] || "interactive_validation_list.xlsx"
|
|
3383
|
-
Xlsxrb.
|
|
3391
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3384
3392
|
wb.sheet("List Validation") do |s|
|
|
3385
3393
|
s.column(0, width: 25)
|
|
3386
3394
|
s.column(1, width: 25)
|
|
@@ -3392,7 +3400,7 @@ end
|
|
|
3392
3400
|
# 2. Read the generated sheet and print data validations
|
|
3393
3401
|
puts "=== Read Validation ==="
|
|
3394
3402
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3395
|
-
workbook = Xlsxrb.read(output_path)
|
|
3403
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3396
3404
|
sheet = workbook.sheets.first
|
|
3397
3405
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3398
3406
|
validations.each do |v|
|
|
@@ -3429,7 +3437,7 @@ Demonstrates range constraints for whole number validations. Open the sheet in E
|
|
|
3429
3437
|
|
|
3430
3438
|
require "xlsxrb"
|
|
3431
3439
|
output_path = ARGV[0] || "interactive_validation_range.xlsx"
|
|
3432
|
-
Xlsxrb.
|
|
3440
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3433
3441
|
wb.sheet("Range Validation") do |s|
|
|
3434
3442
|
s.column(0, width: 25)
|
|
3435
3443
|
s.column(1, width: 25)
|
|
@@ -3441,7 +3449,7 @@ end
|
|
|
3441
3449
|
# 2. Read the generated sheet and print data validations
|
|
3442
3450
|
puts "=== Read Validation ==="
|
|
3443
3451
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3444
|
-
workbook = Xlsxrb.read(output_path)
|
|
3452
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3445
3453
|
sheet = workbook.sheets.first
|
|
3446
3454
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3447
3455
|
validations.each do |v|
|
|
@@ -3478,7 +3486,7 @@ Demonstrates interactive text length validation rules.
|
|
|
3478
3486
|
|
|
3479
3487
|
require "xlsxrb"
|
|
3480
3488
|
output_path = ARGV[0] || "interactive_validation_text_length.xlsx"
|
|
3481
|
-
Xlsxrb.
|
|
3489
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3482
3490
|
wb.sheet("Text Length") do |s|
|
|
3483
3491
|
s.column(0, width: 25)
|
|
3484
3492
|
s.column(1, width: 25)
|
|
@@ -3490,7 +3498,7 @@ end
|
|
|
3490
3498
|
# 2. Read the generated sheet and print data validations
|
|
3491
3499
|
puts "=== Read Validation ==="
|
|
3492
3500
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3493
|
-
workbook = Xlsxrb.read(output_path)
|
|
3501
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3494
3502
|
sheet = workbook.sheets.first
|
|
3495
3503
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3496
3504
|
validations.each do |v|
|
|
@@ -3527,7 +3535,7 @@ Demonstrates interactive time validation rules.
|
|
|
3527
3535
|
|
|
3528
3536
|
require "xlsxrb"
|
|
3529
3537
|
output_path = ARGV[0] || "interactive_validation_time.xlsx"
|
|
3530
|
-
Xlsxrb.
|
|
3538
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3531
3539
|
wb.sheet("Time Validation") do |s|
|
|
3532
3540
|
s.column(0, width: 25)
|
|
3533
3541
|
s.column(1, width: 25)
|
|
@@ -3539,7 +3547,7 @@ end
|
|
|
3539
3547
|
# 2. Read the generated sheet and print data validations
|
|
3540
3548
|
puts "=== Read Validation ==="
|
|
3541
3549
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3542
|
-
workbook = Xlsxrb.read(output_path)
|
|
3550
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3543
3551
|
sheet = workbook.sheets.first
|
|
3544
3552
|
validations = reader.data_validations(sheet: sheet.name)
|
|
3545
3553
|
validations.each do |v|
|
|
@@ -3573,7 +3581,7 @@ require "xlsxrb"
|
|
|
3573
3581
|
|
|
3574
3582
|
output_path = ARGV[0] || "japanese_text.xlsx"
|
|
3575
3583
|
|
|
3576
|
-
Xlsxrb.
|
|
3584
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3577
3585
|
wb.style("ja_font") do |style|
|
|
3578
3586
|
style.font_name("Noto Sans CJK JP").size(12)
|
|
3579
3587
|
end
|
|
@@ -3588,7 +3596,7 @@ end
|
|
|
3588
3596
|
|
|
3589
3597
|
# 2. Read the generated sheet and print parsed cell values and Ruby classes
|
|
3590
3598
|
puts "=== Read Validation ==="
|
|
3591
|
-
workbook = Xlsxrb.read(output_path)
|
|
3599
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3592
3600
|
sheet = workbook.sheets.first
|
|
3593
3601
|
sheet.rows.each do |row|
|
|
3594
3602
|
row_cells = row.cells.map do |c|
|
|
@@ -3625,7 +3633,7 @@ require "xlsxrb"
|
|
|
3625
3633
|
|
|
3626
3634
|
output_path = ARGV[0] || "merge_freeze.xlsx"
|
|
3627
3635
|
|
|
3628
|
-
Xlsxrb.
|
|
3636
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3629
3637
|
wb.style("title") { |style| style.border_all(style: "thin", color: "FF000000").align_horizontal("center") }
|
|
3630
3638
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
3631
3639
|
wb.sheet("Merge & Freeze") do |s|
|
|
@@ -3646,7 +3654,7 @@ end
|
|
|
3646
3654
|
|
|
3647
3655
|
# 2. Read the generated sheet and print cell values
|
|
3648
3656
|
puts "=== Read Validation ==="
|
|
3649
|
-
workbook = Xlsxrb.read(output_path)
|
|
3657
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3650
3658
|
sheet = workbook.sheets.first
|
|
3651
3659
|
sheet.rows.first(5).each do |row|
|
|
3652
3660
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -3681,7 +3689,7 @@ Demonstrates enabling printing of grid lines.
|
|
|
3681
3689
|
|
|
3682
3690
|
require "xlsxrb"
|
|
3683
3691
|
output_path = ARGV[0] || "page_grid_lines_print.xlsx"
|
|
3684
|
-
Xlsxrb.
|
|
3692
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3685
3693
|
wb.sheet("Print Grid Lines") do |s|
|
|
3686
3694
|
s.column(0, width: 25)
|
|
3687
3695
|
s.column(1, width: 25)
|
|
@@ -3693,7 +3701,7 @@ end
|
|
|
3693
3701
|
# 2. Read the generated sheet and print page setup properties
|
|
3694
3702
|
puts "=== Read Validation ==="
|
|
3695
3703
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3696
|
-
workbook = Xlsxrb.read(output_path)
|
|
3704
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3697
3705
|
sheet = workbook.sheets.first
|
|
3698
3706
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3699
3707
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3729,7 +3737,7 @@ Demonstrates setting odd page headers and footers.
|
|
|
3729
3737
|
|
|
3730
3738
|
require "xlsxrb"
|
|
3731
3739
|
output_path = ARGV[0] || "page_header_footer.xlsx"
|
|
3732
|
-
Xlsxrb.
|
|
3740
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3733
3741
|
wb.sheet("Header Footer") do |s|
|
|
3734
3742
|
s.column(0, width: 25)
|
|
3735
3743
|
s.column(1, width: 25)
|
|
@@ -3741,7 +3749,7 @@ end
|
|
|
3741
3749
|
# 2. Read the generated sheet and print page setup properties
|
|
3742
3750
|
puts "=== Read Validation ==="
|
|
3743
3751
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3744
|
-
workbook = Xlsxrb.read(output_path)
|
|
3752
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3745
3753
|
sheet = workbook.sheets.first
|
|
3746
3754
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3747
3755
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3777,7 +3785,7 @@ Demonstrates enabling printing of row and column headings.
|
|
|
3777
3785
|
|
|
3778
3786
|
require "xlsxrb"
|
|
3779
3787
|
output_path = ARGV[0] || "page_headings_print.xlsx"
|
|
3780
|
-
Xlsxrb.
|
|
3788
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3781
3789
|
wb.sheet("Print Headings") do |s|
|
|
3782
3790
|
s.column(0, width: 25)
|
|
3783
3791
|
s.column(1, width: 25)
|
|
@@ -3789,7 +3797,7 @@ end
|
|
|
3789
3797
|
# 2. Read the generated sheet and print page setup properties
|
|
3790
3798
|
puts "=== Read Validation ==="
|
|
3791
3799
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3792
|
-
workbook = Xlsxrb.read(output_path)
|
|
3800
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3793
3801
|
sheet = workbook.sheets.first
|
|
3794
3802
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3795
3803
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3825,7 +3833,7 @@ Demonstrates setting narrow page margins.
|
|
|
3825
3833
|
|
|
3826
3834
|
require "xlsxrb"
|
|
3827
3835
|
output_path = ARGV[0] || "page_margins_narrow.xlsx"
|
|
3828
|
-
Xlsxrb.
|
|
3836
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3829
3837
|
wb.sheet("Narrow Margins") do |s|
|
|
3830
3838
|
s.column(0, width: 25)
|
|
3831
3839
|
s.column(1, width: 25)
|
|
@@ -3837,7 +3845,7 @@ end
|
|
|
3837
3845
|
# 2. Read the generated sheet and print page setup properties
|
|
3838
3846
|
puts "=== Read Validation ==="
|
|
3839
3847
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3840
|
-
workbook = Xlsxrb.read(output_path)
|
|
3848
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3841
3849
|
sheet = workbook.sheets.first
|
|
3842
3850
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3843
3851
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3873,7 +3881,7 @@ Demonstrates setting wide page margins.
|
|
|
3873
3881
|
|
|
3874
3882
|
require "xlsxrb"
|
|
3875
3883
|
output_path = ARGV[0] || "page_margins_wide.xlsx"
|
|
3876
|
-
Xlsxrb.
|
|
3884
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3877
3885
|
wb.sheet("Wide Margins") do |s|
|
|
3878
3886
|
s.column(0, width: 25)
|
|
3879
3887
|
s.column(1, width: 25)
|
|
@@ -3885,7 +3893,7 @@ end
|
|
|
3885
3893
|
# 2. Read the generated sheet and print page setup properties
|
|
3886
3894
|
puts "=== Read Validation ==="
|
|
3887
3895
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3888
|
-
workbook = Xlsxrb.read(output_path)
|
|
3896
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3889
3897
|
sheet = workbook.sheets.first
|
|
3890
3898
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3891
3899
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3921,7 +3929,7 @@ Demonstrates landscape page setup for printing.
|
|
|
3921
3929
|
|
|
3922
3930
|
require "xlsxrb"
|
|
3923
3931
|
output_path = ARGV[0] || "page_orientation_landscape.xlsx"
|
|
3924
|
-
Xlsxrb.
|
|
3932
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3925
3933
|
wb.sheet("Landscape") do |s|
|
|
3926
3934
|
s.column(0, width: 25)
|
|
3927
3935
|
s.column(1, width: 25)
|
|
@@ -3933,7 +3941,7 @@ end
|
|
|
3933
3941
|
# 2. Read the generated sheet and print page setup properties
|
|
3934
3942
|
puts "=== Read Validation ==="
|
|
3935
3943
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3936
|
-
workbook = Xlsxrb.read(output_path)
|
|
3944
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3937
3945
|
sheet = workbook.sheets.first
|
|
3938
3946
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3939
3947
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -3969,7 +3977,7 @@ Demonstrates setting paper size to A3 (paper size 8).
|
|
|
3969
3977
|
|
|
3970
3978
|
require "xlsxrb"
|
|
3971
3979
|
output_path = ARGV[0] || "page_paper_size_a3.xlsx"
|
|
3972
|
-
Xlsxrb.
|
|
3980
|
+
Xlsxrb.write(output_path) do |wb|
|
|
3973
3981
|
wb.sheet("A3 Sheet") do |s|
|
|
3974
3982
|
s.column(0, width: 25)
|
|
3975
3983
|
s.column(1, width: 25)
|
|
@@ -3981,7 +3989,7 @@ end
|
|
|
3981
3989
|
# 2. Read the generated sheet and print page setup properties
|
|
3982
3990
|
puts "=== Read Validation ==="
|
|
3983
3991
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
3984
|
-
workbook = Xlsxrb.read(output_path)
|
|
3992
|
+
workbook = Xlsxrb.read(output_path).load
|
|
3985
3993
|
sheet = workbook.sheets.first
|
|
3986
3994
|
margins = reader.page_margins(sheet: sheet.name)
|
|
3987
3995
|
setup = reader.page_setup(sheet: sheet.name)
|
|
@@ -4017,7 +4025,7 @@ Demonstrates outline grouping for rows.
|
|
|
4017
4025
|
|
|
4018
4026
|
require "xlsxrb"
|
|
4019
4027
|
output_path = ARGV[0] || "row_grouping.xlsx"
|
|
4020
|
-
Xlsxrb.
|
|
4028
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4021
4029
|
wb.style("parent") { |style| style.border_all(style: "thin", color: "FF000000").bold }
|
|
4022
4030
|
wb.style("child") { |style| style.border_all(style: "thin", color: "FF000000").align_horizontal("left").indent(2) }
|
|
4023
4031
|
wb.sheet("Row Grouping") do |s|
|
|
@@ -4031,7 +4039,7 @@ end
|
|
|
4031
4039
|
|
|
4032
4040
|
# 2. Read the generated sheet and print row attributes
|
|
4033
4041
|
puts "=== Read Validation ==="
|
|
4034
|
-
workbook = Xlsxrb.read(output_path)
|
|
4042
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4035
4043
|
sheet = workbook.sheets.first
|
|
4036
4044
|
sheet.rows.each do |row|
|
|
4037
4045
|
puts "Row #{row.index}: height=#{row.height}, hidden=#{row.hidden}, outline_level=#{row.outline_level}"
|
|
@@ -4064,7 +4072,7 @@ Demonstrates setting very tall row heights.
|
|
|
4064
4072
|
|
|
4065
4073
|
require "xlsxrb"
|
|
4066
4074
|
output_path = ARGV[0] || "row_height_tall.xlsx"
|
|
4067
|
-
Xlsxrb.
|
|
4075
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4068
4076
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
4069
4077
|
wb.sheet("Row Height") do |s|
|
|
4070
4078
|
s.column(0, width: 25)
|
|
@@ -4076,7 +4084,7 @@ end
|
|
|
4076
4084
|
|
|
4077
4085
|
# 2. Read the generated sheet and print row attributes
|
|
4078
4086
|
puts "=== Read Validation ==="
|
|
4079
|
-
workbook = Xlsxrb.read(output_path)
|
|
4087
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4080
4088
|
sheet = workbook.sheets.first
|
|
4081
4089
|
sheet.rows.each do |row|
|
|
4082
4090
|
puts "Row #{row.index}: height=#{row.height}, hidden=#{row.hidden}, outline_level=#{row.outline_level}"
|
|
@@ -4108,7 +4116,7 @@ Demonstrates setting custom row heights.
|
|
|
4108
4116
|
|
|
4109
4117
|
require "xlsxrb"
|
|
4110
4118
|
output_path = ARGV[0] || "row_heights.xlsx"
|
|
4111
|
-
Xlsxrb.
|
|
4119
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4112
4120
|
wb.style("border") { |style| style.border_all(style: "thin", color: "FF000000") }
|
|
4113
4121
|
wb.sheet("Heights") do |s|
|
|
4114
4122
|
s.column(0, width: 25)
|
|
@@ -4120,7 +4128,7 @@ end
|
|
|
4120
4128
|
|
|
4121
4129
|
# 2. Read the generated sheet and print row attributes
|
|
4122
4130
|
puts "=== Read Validation ==="
|
|
4123
|
-
workbook = Xlsxrb.read(output_path)
|
|
4131
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4124
4132
|
sheet = workbook.sheets.first
|
|
4125
4133
|
sheet.rows.each do |row|
|
|
4126
4134
|
puts "Row #{row.index}: height=#{row.height}, hidden=#{row.hidden}, outline_level=#{row.outline_level}"
|
|
@@ -4156,7 +4164,7 @@ Demonstrates customizing tab colors of individual worksheets.
|
|
|
4156
4164
|
|
|
4157
4165
|
require "xlsxrb"
|
|
4158
4166
|
output_path = ARGV[0] || "sheet_tab_colors.xlsx"
|
|
4159
|
-
Xlsxrb.
|
|
4167
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4160
4168
|
wb.sheet("Red Tab") do |s|
|
|
4161
4169
|
s.column(0, width: 25)
|
|
4162
4170
|
s.column(1, width: 25)
|
|
@@ -4172,7 +4180,7 @@ end
|
|
|
4172
4180
|
# 2. Read the generated sheet and print sheet properties
|
|
4173
4181
|
puts "=== Read Validation ==="
|
|
4174
4182
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
4175
|
-
workbook = Xlsxrb.read(output_path)
|
|
4183
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4176
4184
|
workbook.sheet_names.each do |s_name|
|
|
4177
4185
|
props = reader.sheet_properties(sheet: s_name)
|
|
4178
4186
|
puts "Sheet: #{s_name}, tab color: #{props[:tab_color].inspect}"
|
|
@@ -4204,7 +4212,7 @@ Demonstrates embedded column sparklines in cell ranges.
|
|
|
4204
4212
|
|
|
4205
4213
|
require "xlsxrb"
|
|
4206
4214
|
output_path = ARGV[0] || "sparkline_column.xlsx"
|
|
4207
|
-
Xlsxrb.
|
|
4215
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4208
4216
|
wb.sheet("Sparkline") do |s|
|
|
4209
4217
|
s.sheet_properties(:fit_to_page, true)
|
|
4210
4218
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -4220,7 +4228,7 @@ end
|
|
|
4220
4228
|
|
|
4221
4229
|
# 2. Read the generated sheet and print cell values
|
|
4222
4230
|
puts "=== Read Validation ==="
|
|
4223
|
-
workbook = Xlsxrb.read(output_path)
|
|
4231
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4224
4232
|
sheet = workbook.sheets.first
|
|
4225
4233
|
sheet.rows.first(3).each do |row|
|
|
4226
4234
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -4254,7 +4262,7 @@ Demonstrates embedded line sparklines in cell ranges.
|
|
|
4254
4262
|
|
|
4255
4263
|
require "xlsxrb"
|
|
4256
4264
|
output_path = ARGV[0] || "sparkline_line.xlsx"
|
|
4257
|
-
Xlsxrb.
|
|
4265
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4258
4266
|
wb.sheet("Sparkline") do |s|
|
|
4259
4267
|
s.sheet_properties(:fit_to_page, true)
|
|
4260
4268
|
s.page_setup(fit_to_width: 1, fit_to_height: 1)
|
|
@@ -4273,7 +4281,7 @@ end
|
|
|
4273
4281
|
|
|
4274
4282
|
# 2. Read the generated sheet and print cell values
|
|
4275
4283
|
puts "=== Read Validation ==="
|
|
4276
|
-
workbook = Xlsxrb.read(output_path)
|
|
4284
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4277
4285
|
sheet = workbook.sheets.first
|
|
4278
4286
|
sheet.rows.first(3).each do |row|
|
|
4279
4287
|
row_cells = row.cells.map { |c| "#{c.ref}: #{c.value.inspect}" }
|
|
@@ -4307,7 +4315,7 @@ require "xlsxrb"
|
|
|
4307
4315
|
|
|
4308
4316
|
output_path = ARGV[0] || "styles_fonts_fills.xlsx"
|
|
4309
4317
|
|
|
4310
|
-
Xlsxrb.
|
|
4318
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4311
4319
|
wb.style("header") do |style|
|
|
4312
4320
|
style.bold.size(14).font_color("FFFFFFFF").fill_color("FF4F81BD")
|
|
4313
4321
|
end
|
|
@@ -4326,7 +4334,7 @@ end
|
|
|
4326
4334
|
|
|
4327
4335
|
# 2. Read the generated sheet and print styling details
|
|
4328
4336
|
puts "=== Read Validation ==="
|
|
4329
|
-
workbook = Xlsxrb.read(output_path)
|
|
4337
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4330
4338
|
sheet = workbook.sheets.first
|
|
4331
4339
|
sheet.rows.first(4).each do |row|
|
|
4332
4340
|
row_cells = row.cells.map do |c|
|
|
@@ -4366,7 +4374,7 @@ Demonstrates disabling visible grid lines in spreadsheet view.
|
|
|
4366
4374
|
|
|
4367
4375
|
require "xlsxrb"
|
|
4368
4376
|
output_path = ARGV[0] || "view_show_grid_lines.xlsx"
|
|
4369
|
-
Xlsxrb.
|
|
4377
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4370
4378
|
wb.sheet("Hide Grid Lines") do |s|
|
|
4371
4379
|
s.column(0, width: 25)
|
|
4372
4380
|
s.column(1, width: 25)
|
|
@@ -4378,7 +4386,7 @@ end
|
|
|
4378
4386
|
# 2. Read the generated sheet and print view configurations
|
|
4379
4387
|
puts "=== Read Validation ==="
|
|
4380
4388
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
4381
|
-
workbook = Xlsxrb.read(output_path)
|
|
4389
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4382
4390
|
workbook.sheet_names.each do |s_name|
|
|
4383
4391
|
view = reader.sheet_view(sheet: s_name)
|
|
4384
4392
|
puts "Sheet '#{s_name}' views zoom scale: #{view[:zoom_scale]}%, show grid lines: #{view[:show_grid_lines]}"
|
|
@@ -4411,7 +4419,7 @@ Demonstrates setting custom zoom scale in sheet view (e.g. 150%).
|
|
|
4411
4419
|
|
|
4412
4420
|
require "xlsxrb"
|
|
4413
4421
|
output_path = ARGV[0] || "view_zoom_scale.xlsx"
|
|
4414
|
-
Xlsxrb.
|
|
4422
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4415
4423
|
wb.sheet("Zoom 150") do |s|
|
|
4416
4424
|
s.column(0, width: 25)
|
|
4417
4425
|
s.column(1, width: 25)
|
|
@@ -4423,7 +4431,7 @@ end
|
|
|
4423
4431
|
# 2. Read the generated sheet and print view configurations
|
|
4424
4432
|
puts "=== Read Validation ==="
|
|
4425
4433
|
reader = Xlsxrb::Ooxml::Reader.new(output_path)
|
|
4426
|
-
workbook = Xlsxrb.read(output_path)
|
|
4434
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4427
4435
|
workbook.sheet_names.each do |s_name|
|
|
4428
4436
|
view = reader.sheet_view(sheet: s_name)
|
|
4429
4437
|
puts "Sheet '#{s_name}' views zoom scale: #{view[:zoom_scale]}%, show grid lines: #{view[:show_grid_lines]}"
|
|
@@ -4458,7 +4466,7 @@ Demonstrates creating workbooks with multiple worksheets.
|
|
|
4458
4466
|
|
|
4459
4467
|
require "xlsxrb"
|
|
4460
4468
|
output_path = ARGV[0] || "workbook_three_sheets.xlsx"
|
|
4461
|
-
Xlsxrb.
|
|
4469
|
+
Xlsxrb.write(output_path) do |wb|
|
|
4462
4470
|
wb.sheet("First Sheet") { |s| s.row(["First Sheet Data"]) }
|
|
4463
4471
|
wb.sheet("Second Sheet") { |s| s.row(["Second Sheet Data"]) }
|
|
4464
4472
|
wb.sheet("Third Sheet") { |s| s.row(["Third Sheet Data"]) }
|
|
@@ -4466,7 +4474,7 @@ end
|
|
|
4466
4474
|
|
|
4467
4475
|
# 2. Read the generated sheet and print the sheets structure
|
|
4468
4476
|
puts "=== Read Validation ==="
|
|
4469
|
-
workbook = Xlsxrb.read(output_path)
|
|
4477
|
+
workbook = Xlsxrb.read(output_path).load
|
|
4470
4478
|
puts "Workbook sheets: #{workbook.sheet_names.join(", ")}"
|
|
4471
4479
|
```
|
|
4472
4480
|
|