write_xlsx 1.08.2 → 1.09.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +9 -0
  3. data/README.md +1 -1
  4. data/examples/background.rb +19 -0
  5. data/lib/write_xlsx/chart/axis.rb +3 -3
  6. data/lib/write_xlsx/chart/scatter.rb +0 -15
  7. data/lib/write_xlsx/chart/series.rb +1 -1
  8. data/lib/write_xlsx/chart.rb +28 -28
  9. data/lib/write_xlsx/chartsheet.rb +3 -3
  10. data/lib/write_xlsx/drawing.rb +39 -39
  11. data/lib/write_xlsx/format.rb +11 -179
  12. data/lib/write_xlsx/package/app.rb +2 -2
  13. data/lib/write_xlsx/package/button.rb +8 -8
  14. data/lib/write_xlsx/package/comments.rb +8 -8
  15. data/lib/write_xlsx/package/content_types.rb +18 -9
  16. data/lib/write_xlsx/package/core.rb +5 -5
  17. data/lib/write_xlsx/package/custom.rb +2 -2
  18. data/lib/write_xlsx/package/metadata.rb +159 -0
  19. data/lib/write_xlsx/package/packager.rb +21 -0
  20. data/lib/write_xlsx/package/shared_strings.rb +6 -6
  21. data/lib/write_xlsx/package/styles.rb +11 -11
  22. data/lib/write_xlsx/package/table.rb +23 -23
  23. data/lib/write_xlsx/package/theme.rb +1 -1
  24. data/lib/write_xlsx/package/vml.rb +43 -43
  25. data/lib/write_xlsx/shape.rb +17 -15
  26. data/lib/write_xlsx/sparkline.rb +340 -340
  27. data/lib/write_xlsx/utility.rb +4 -23
  28. data/lib/write_xlsx/version.rb +1 -1
  29. data/lib/write_xlsx/workbook.rb +171 -644
  30. data/lib/write_xlsx/worksheet/cell_data.rb +25 -3
  31. data/lib/write_xlsx/worksheet/data_validation.rb +20 -20
  32. data/lib/write_xlsx/worksheet/hyperlink.rb +4 -4
  33. data/lib/write_xlsx/worksheet/page_setup.rb +12 -12
  34. data/lib/write_xlsx/worksheet.rb +295 -4184
  35. data/test/perl_output/background.xlsx +0 -0
  36. data/test/regression/images/logo.gif +0 -0
  37. data/test/regression/images/logo.jpg +0 -0
  38. data/test/regression/images/red.gif +0 -0
  39. data/test/regression/test_background01.rb +23 -0
  40. data/test/regression/test_background02.rb +23 -0
  41. data/test/regression/test_background03.rb +24 -0
  42. data/test/regression/test_background04.rb +25 -0
  43. data/test/regression/test_background05.rb +25 -0
  44. data/test/regression/test_background06.rb +31 -0
  45. data/test/regression/test_background07.rb +37 -0
  46. data/test/regression/test_chart_axis47.rb +52 -0
  47. data/test/regression/test_chart_axis48.rb +53 -0
  48. data/test/regression/test_dynamic_array01.rb +25 -0
  49. data/test/regression/test_image56.rb +23 -0
  50. data/test/regression/test_image57.rb +23 -0
  51. data/test/regression/test_set_column10.rb +55 -0
  52. data/test/regression/test_set_column11.rb +48 -0
  53. data/test/regression/test_set_row01.rb +35 -0
  54. data/test/regression/test_set_row02.rb +35 -0
  55. data/test/regression/test_set_row03.rb +35 -0
  56. data/test/regression/test_set_row04.rb +35 -0
  57. data/test/regression/xlsx_files/background01.xlsx +0 -0
  58. data/test/regression/xlsx_files/background02.xlsx +0 -0
  59. data/test/regression/xlsx_files/background03.xlsx +0 -0
  60. data/test/regression/xlsx_files/background04.xlsx +0 -0
  61. data/test/regression/xlsx_files/background05.xlsx +0 -0
  62. data/test/regression/xlsx_files/background06.xlsx +0 -0
  63. data/test/regression/xlsx_files/background07.xlsx +0 -0
  64. data/test/regression/xlsx_files/chart_axis47.xlsx +0 -0
  65. data/test/regression/xlsx_files/chart_axis48.xlsx +0 -0
  66. data/test/regression/xlsx_files/dynamic_array01.xlsx +0 -0
  67. data/test/regression/xlsx_files/image56.xlsx +0 -0
  68. data/test/regression/xlsx_files/image57.xlsx +0 -0
  69. data/test/regression/xlsx_files/set_row01.xlsx +0 -0
  70. data/test/regression/xlsx_files/set_row03.xlsx +0 -0
  71. data/test/test_example_match.rb +12 -0
  72. data/test/worksheet/test_pixels_to_row_col.rb +46 -0
  73. metadata +78 -2
@@ -242,6 +242,18 @@ class TestExampleMatch < Minitest::Test
242
242
  compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
243
243
  end
244
244
 
245
+ def teset_background
246
+ @xlsx = 'background.xlsx'
247
+ workbook = WriteXLSX.new(@io)
248
+
249
+ worksheet = workbook.add_worksheet
250
+ worksheet.set_background(File.join(@test_dir, 'republic.png'))
251
+
252
+ workbook.close
253
+ store_to_tempfile
254
+ compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
255
+ end
256
+
245
257
  def test_chart_data_labels
246
258
  @xlsx = 'chart_data_labels.xlsx'
247
259
  workbook = WriteXLSX.new(@io)
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestPixelsToRowCol < Minitest::Test
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet('')
10
+ end
11
+
12
+ def width_to_pixels(width)
13
+ max_digit_width = 7.0
14
+ padding = 5
15
+
16
+ if width < 1
17
+ pixels = (width * (max_digit_width + padding) + 0.5).to_i
18
+ else
19
+ pixels = (width * max_digit_width + 0.5).to_i + padding
20
+ end
21
+
22
+ pixels
23
+ end
24
+
25
+ def height_to_pixels(height)
26
+ (4.0 * height / 3).to_i
27
+ end
28
+
29
+ def test_pixel_to_width
30
+ (0..1790).each do |pixels|
31
+ caption = "\tWorksheet: pixcel_to_width(#{pixels})"
32
+ expected = pixels
33
+ result = width_to_pixels(@worksheet.__send__(:pixels_to_width, pixels))
34
+ assert_equal(expected, result, caption)
35
+ end
36
+ end
37
+
38
+ def test_pixel_to_height
39
+ (0..545).each do |pixels|
40
+ caption = "\tWorksheet: pixcel_to_height(#{pixels})"
41
+ expected = pixels
42
+ result = height_to_pixels(@worksheet.__send__(:pixels_to_height, pixels))
43
+ assert_equal(expected, result, caption)
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: write_xlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.08.2
4
+ version: 1.09.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-20 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -105,6 +105,7 @@ files:
105
105
  - examples/add_vba_project.rb
106
106
  - examples/array_formula.rb
107
107
  - examples/autofilter.rb
108
+ - examples/background.rb
108
109
  - examples/chart_area.rb
109
110
  - examples/chart_bar.rb
110
111
  - examples/chart_clustered.rb
@@ -204,6 +205,7 @@ files:
204
205
  - lib/write_xlsx/package/content_types.rb
205
206
  - lib/write_xlsx/package/core.rb
206
207
  - lib/write_xlsx/package/custom.rb
208
+ - lib/write_xlsx/package/metadata.rb
207
209
  - lib/write_xlsx/package/packager.rb
208
210
  - lib/write_xlsx/package/relationships.rb
209
211
  - lib/write_xlsx/package/shared_strings.rb
@@ -334,6 +336,7 @@ files:
334
336
  - test/perl_output/add_vba_project.xlsm
335
337
  - test/perl_output/array_formula.xlsx
336
338
  - test/perl_output/autofilter.xlsx
339
+ - test/perl_output/background.xlsx
337
340
  - test/perl_output/chart_area.xlsx
338
341
  - test/perl_output/chart_bar.xlsx
339
342
  - test/perl_output/chart_column.xlsx
@@ -418,9 +421,12 @@ files:
418
421
  - test/regression/images/grey.png
419
422
  - test/regression/images/happy.jpg
420
423
  - test/regression/images/issue32.png
424
+ - test/regression/images/logo.gif
425
+ - test/regression/images/logo.jpg
421
426
  - test/regression/images/logo.png
422
427
  - test/regression/images/mylogo.png
423
428
  - test/regression/images/red.bmp
429
+ - test/regression/images/red.gif
424
430
  - test/regression/images/red.jpg
425
431
  - test/regression/images/red.png
426
432
  - test/regression/images/red2.png
@@ -446,6 +452,13 @@ files:
446
452
  - test/regression/test_autofilter08.rb
447
453
  - test/regression/test_autofilter09.rb
448
454
  - test/regression/test_autofilter10.rb
455
+ - test/regression/test_background01.rb
456
+ - test/regression/test_background02.rb
457
+ - test/regression/test_background03.rb
458
+ - test/regression/test_background04.rb
459
+ - test/regression/test_background05.rb
460
+ - test/regression/test_background06.rb
461
+ - test/regression/test_background07.rb
449
462
  - test/regression/test_button01.rb
450
463
  - test/regression/test_button02.rb
451
464
  - test/regression/test_button03.rb
@@ -506,6 +519,8 @@ files:
506
519
  - test/regression/test_chart_axis44.rb
507
520
  - test/regression/test_chart_axis45.rb
508
521
  - test/regression/test_chart_axis46.rb
522
+ - test/regression/test_chart_axis47.rb
523
+ - test/regression/test_chart_axis48.rb
509
524
  - test/regression/test_chart_bar01.rb
510
525
  - test/regression/test_chart_bar02.rb
511
526
  - test/regression/test_chart_bar03.rb
@@ -871,6 +886,7 @@ files:
871
886
  - test/regression/test_defined_name02.rb
872
887
  - test/regression/test_defined_name03.rb
873
888
  - test/regression/test_defined_name04.rb
889
+ - test/regression/test_dynamic_array01.rb
874
890
  - test/regression/test_escapes01.rb
875
891
  - test/regression/test_escapes02.rb
876
892
  - test/regression/test_escapes03.rb
@@ -1030,6 +1046,8 @@ files:
1030
1046
  - test/regression/test_image53.rb
1031
1047
  - test/regression/test_image54.rb
1032
1048
  - test/regression/test_image55.rb
1049
+ - test/regression/test_image56.rb
1050
+ - test/regression/test_image57.rb
1033
1051
  - test/regression/test_landscape01.rb
1034
1052
  - test/regression/test_macro01.rb
1035
1053
  - test/regression/test_merge_cells01.rb
@@ -1144,7 +1162,13 @@ files:
1144
1162
  - test/regression/test_set_column07.rb
1145
1163
  - test/regression/test_set_column08.rb
1146
1164
  - test/regression/test_set_column09.rb
1165
+ - test/regression/test_set_column10.rb
1166
+ - test/regression/test_set_column11.rb
1147
1167
  - test/regression/test_set_print_scale01.rb
1168
+ - test/regression/test_set_row01.rb
1169
+ - test/regression/test_set_row02.rb
1170
+ - test/regression/test_set_row03.rb
1171
+ - test/regression/test_set_row04.rb
1148
1172
  - test/regression/test_set_start_page01.rb
1149
1173
  - test/regression/test_set_start_page02.rb
1150
1174
  - test/regression/test_set_start_page03.rb
@@ -1226,6 +1250,13 @@ files:
1226
1250
  - test/regression/xlsx_files/autofilter08.xlsx
1227
1251
  - test/regression/xlsx_files/autofilter09.xlsx
1228
1252
  - test/regression/xlsx_files/autofilter10.xlsx
1253
+ - test/regression/xlsx_files/background01.xlsx
1254
+ - test/regression/xlsx_files/background02.xlsx
1255
+ - test/regression/xlsx_files/background03.xlsx
1256
+ - test/regression/xlsx_files/background04.xlsx
1257
+ - test/regression/xlsx_files/background05.xlsx
1258
+ - test/regression/xlsx_files/background06.xlsx
1259
+ - test/regression/xlsx_files/background07.xlsx
1229
1260
  - test/regression/xlsx_files/button01.xlsx
1230
1261
  - test/regression/xlsx_files/button02.xlsx
1231
1262
  - test/regression/xlsx_files/button03.xlsx
@@ -1287,6 +1318,8 @@ files:
1287
1318
  - test/regression/xlsx_files/chart_axis44.xlsx
1288
1319
  - test/regression/xlsx_files/chart_axis45.xlsx
1289
1320
  - test/regression/xlsx_files/chart_axis46.xlsx
1321
+ - test/regression/xlsx_files/chart_axis47.xlsx
1322
+ - test/regression/xlsx_files/chart_axis48.xlsx
1290
1323
  - test/regression/xlsx_files/chart_bar01.xlsx
1291
1324
  - test/regression/xlsx_files/chart_bar02.xlsx
1292
1325
  - test/regression/xlsx_files/chart_bar03.xlsx
@@ -1643,6 +1676,7 @@ files:
1643
1676
  - test/regression/xlsx_files/defined_name02.xlsx
1644
1677
  - test/regression/xlsx_files/defined_name03.xlsx
1645
1678
  - test/regression/xlsx_files/defined_name04.xlsx
1679
+ - test/regression/xlsx_files/dynamic_array01.xlsx
1646
1680
  - test/regression/xlsx_files/escapes01.xlsx
1647
1681
  - test/regression/xlsx_files/escapes02.xlsx
1648
1682
  - test/regression/xlsx_files/escapes03.xlsx
@@ -1805,6 +1839,8 @@ files:
1805
1839
  - test/regression/xlsx_files/image53.xlsx
1806
1840
  - test/regression/xlsx_files/image54.xlsx
1807
1841
  - test/regression/xlsx_files/image55.xlsx
1842
+ - test/regression/xlsx_files/image56.xlsx
1843
+ - test/regression/xlsx_files/image57.xlsx
1808
1844
  - test/regression/xlsx_files/landscape01.xlsx
1809
1845
  - test/regression/xlsx_files/macro01.xlsm
1810
1846
  - test/regression/xlsx_files/merge_cells01.xlsx
@@ -1920,6 +1956,8 @@ files:
1920
1956
  - test/regression/xlsx_files/set_column08.xlsx
1921
1957
  - test/regression/xlsx_files/set_column09.xlsx
1922
1958
  - test/regression/xlsx_files/set_print_scale01.xlsx
1959
+ - test/regression/xlsx_files/set_row01.xlsx
1960
+ - test/regression/xlsx_files/set_row03.xlsx
1923
1961
  - test/regression/xlsx_files/set_start_page01.xlsx
1924
1962
  - test/regression/xlsx_files/set_start_page02.xlsx
1925
1963
  - test/regression/xlsx_files/set_start_page03.xlsx
@@ -2052,6 +2090,7 @@ files:
2052
2090
  - test/worksheet/test_data_bar_12.rb
2053
2091
  - test/worksheet/test_extract_filter_tokens.rb
2054
2092
  - test/worksheet/test_parse_filter_expression.rb
2093
+ - test/worksheet/test_pixels_to_row_col.rb
2055
2094
  - test/worksheet/test_position_object.rb
2056
2095
  - test/worksheet/test_repeat_formula.rb
2057
2096
  - test/worksheet/test_sparkline_01.rb
@@ -2255,6 +2294,7 @@ test_files:
2255
2294
  - test/perl_output/add_vba_project.xlsm
2256
2295
  - test/perl_output/array_formula.xlsx
2257
2296
  - test/perl_output/autofilter.xlsx
2297
+ - test/perl_output/background.xlsx
2258
2298
  - test/perl_output/chart_area.xlsx
2259
2299
  - test/perl_output/chart_bar.xlsx
2260
2300
  - test/perl_output/chart_column.xlsx
@@ -2339,9 +2379,12 @@ test_files:
2339
2379
  - test/regression/images/grey.png
2340
2380
  - test/regression/images/happy.jpg
2341
2381
  - test/regression/images/issue32.png
2382
+ - test/regression/images/logo.gif
2383
+ - test/regression/images/logo.jpg
2342
2384
  - test/regression/images/logo.png
2343
2385
  - test/regression/images/mylogo.png
2344
2386
  - test/regression/images/red.bmp
2387
+ - test/regression/images/red.gif
2345
2388
  - test/regression/images/red.jpg
2346
2389
  - test/regression/images/red.png
2347
2390
  - test/regression/images/red2.png
@@ -2367,6 +2410,13 @@ test_files:
2367
2410
  - test/regression/test_autofilter08.rb
2368
2411
  - test/regression/test_autofilter09.rb
2369
2412
  - test/regression/test_autofilter10.rb
2413
+ - test/regression/test_background01.rb
2414
+ - test/regression/test_background02.rb
2415
+ - test/regression/test_background03.rb
2416
+ - test/regression/test_background04.rb
2417
+ - test/regression/test_background05.rb
2418
+ - test/regression/test_background06.rb
2419
+ - test/regression/test_background07.rb
2370
2420
  - test/regression/test_button01.rb
2371
2421
  - test/regression/test_button02.rb
2372
2422
  - test/regression/test_button03.rb
@@ -2427,6 +2477,8 @@ test_files:
2427
2477
  - test/regression/test_chart_axis44.rb
2428
2478
  - test/regression/test_chart_axis45.rb
2429
2479
  - test/regression/test_chart_axis46.rb
2480
+ - test/regression/test_chart_axis47.rb
2481
+ - test/regression/test_chart_axis48.rb
2430
2482
  - test/regression/test_chart_bar01.rb
2431
2483
  - test/regression/test_chart_bar02.rb
2432
2484
  - test/regression/test_chart_bar03.rb
@@ -2792,6 +2844,7 @@ test_files:
2792
2844
  - test/regression/test_defined_name02.rb
2793
2845
  - test/regression/test_defined_name03.rb
2794
2846
  - test/regression/test_defined_name04.rb
2847
+ - test/regression/test_dynamic_array01.rb
2795
2848
  - test/regression/test_escapes01.rb
2796
2849
  - test/regression/test_escapes02.rb
2797
2850
  - test/regression/test_escapes03.rb
@@ -2951,6 +3004,8 @@ test_files:
2951
3004
  - test/regression/test_image53.rb
2952
3005
  - test/regression/test_image54.rb
2953
3006
  - test/regression/test_image55.rb
3007
+ - test/regression/test_image56.rb
3008
+ - test/regression/test_image57.rb
2954
3009
  - test/regression/test_landscape01.rb
2955
3010
  - test/regression/test_macro01.rb
2956
3011
  - test/regression/test_merge_cells01.rb
@@ -3065,7 +3120,13 @@ test_files:
3065
3120
  - test/regression/test_set_column07.rb
3066
3121
  - test/regression/test_set_column08.rb
3067
3122
  - test/regression/test_set_column09.rb
3123
+ - test/regression/test_set_column10.rb
3124
+ - test/regression/test_set_column11.rb
3068
3125
  - test/regression/test_set_print_scale01.rb
3126
+ - test/regression/test_set_row01.rb
3127
+ - test/regression/test_set_row02.rb
3128
+ - test/regression/test_set_row03.rb
3129
+ - test/regression/test_set_row04.rb
3069
3130
  - test/regression/test_set_start_page01.rb
3070
3131
  - test/regression/test_set_start_page02.rb
3071
3132
  - test/regression/test_set_start_page03.rb
@@ -3147,6 +3208,13 @@ test_files:
3147
3208
  - test/regression/xlsx_files/autofilter08.xlsx
3148
3209
  - test/regression/xlsx_files/autofilter09.xlsx
3149
3210
  - test/regression/xlsx_files/autofilter10.xlsx
3211
+ - test/regression/xlsx_files/background01.xlsx
3212
+ - test/regression/xlsx_files/background02.xlsx
3213
+ - test/regression/xlsx_files/background03.xlsx
3214
+ - test/regression/xlsx_files/background04.xlsx
3215
+ - test/regression/xlsx_files/background05.xlsx
3216
+ - test/regression/xlsx_files/background06.xlsx
3217
+ - test/regression/xlsx_files/background07.xlsx
3150
3218
  - test/regression/xlsx_files/button01.xlsx
3151
3219
  - test/regression/xlsx_files/button02.xlsx
3152
3220
  - test/regression/xlsx_files/button03.xlsx
@@ -3208,6 +3276,8 @@ test_files:
3208
3276
  - test/regression/xlsx_files/chart_axis44.xlsx
3209
3277
  - test/regression/xlsx_files/chart_axis45.xlsx
3210
3278
  - test/regression/xlsx_files/chart_axis46.xlsx
3279
+ - test/regression/xlsx_files/chart_axis47.xlsx
3280
+ - test/regression/xlsx_files/chart_axis48.xlsx
3211
3281
  - test/regression/xlsx_files/chart_bar01.xlsx
3212
3282
  - test/regression/xlsx_files/chart_bar02.xlsx
3213
3283
  - test/regression/xlsx_files/chart_bar03.xlsx
@@ -3564,6 +3634,7 @@ test_files:
3564
3634
  - test/regression/xlsx_files/defined_name02.xlsx
3565
3635
  - test/regression/xlsx_files/defined_name03.xlsx
3566
3636
  - test/regression/xlsx_files/defined_name04.xlsx
3637
+ - test/regression/xlsx_files/dynamic_array01.xlsx
3567
3638
  - test/regression/xlsx_files/escapes01.xlsx
3568
3639
  - test/regression/xlsx_files/escapes02.xlsx
3569
3640
  - test/regression/xlsx_files/escapes03.xlsx
@@ -3726,6 +3797,8 @@ test_files:
3726
3797
  - test/regression/xlsx_files/image53.xlsx
3727
3798
  - test/regression/xlsx_files/image54.xlsx
3728
3799
  - test/regression/xlsx_files/image55.xlsx
3800
+ - test/regression/xlsx_files/image56.xlsx
3801
+ - test/regression/xlsx_files/image57.xlsx
3729
3802
  - test/regression/xlsx_files/landscape01.xlsx
3730
3803
  - test/regression/xlsx_files/macro01.xlsm
3731
3804
  - test/regression/xlsx_files/merge_cells01.xlsx
@@ -3841,6 +3914,8 @@ test_files:
3841
3914
  - test/regression/xlsx_files/set_column08.xlsx
3842
3915
  - test/regression/xlsx_files/set_column09.xlsx
3843
3916
  - test/regression/xlsx_files/set_print_scale01.xlsx
3917
+ - test/regression/xlsx_files/set_row01.xlsx
3918
+ - test/regression/xlsx_files/set_row03.xlsx
3844
3919
  - test/regression/xlsx_files/set_start_page01.xlsx
3845
3920
  - test/regression/xlsx_files/set_start_page02.xlsx
3846
3921
  - test/regression/xlsx_files/set_start_page03.xlsx
@@ -3973,6 +4048,7 @@ test_files:
3973
4048
  - test/worksheet/test_data_bar_12.rb
3974
4049
  - test/worksheet/test_extract_filter_tokens.rb
3975
4050
  - test/worksheet/test_parse_filter_expression.rb
4051
+ - test/worksheet/test_pixels_to_row_col.rb
3976
4052
  - test/worksheet/test_position_object.rb
3977
4053
  - test/worksheet/test_repeat_formula.rb
3978
4054
  - test/worksheet/test_sparkline_01.rb