write_xlsx 1.04.0 → 1.08.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Changes +50 -0
- data/README.md +1 -1
- data/examples/chart_data_labels.rb +320 -0
- data/examples/ignore_errors.rb +39 -0
- data/ignore_errors.xlsx +0 -0
- data/lib/write_xlsx/chart/series.rb +100 -0
- data/lib/write_xlsx/chart.rb +155 -33
- data/lib/write_xlsx/drawing.rb +80 -17
- data/lib/write_xlsx/package/app.rb +3 -3
- data/lib/write_xlsx/package/conditional_format.rb +2 -8
- data/lib/write_xlsx/package/packager.rb +1 -0
- data/lib/write_xlsx/package/styles.rb +16 -3
- data/lib/write_xlsx/package/table.rb +8 -0
- data/lib/write_xlsx/utility.rb +9 -3
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +23 -0
- data/lib/write_xlsx/worksheet/data_validation.rb +1 -6
- data/lib/write_xlsx/worksheet.rb +160 -37
- data/test/drawing/{test_write_ext.rb → test_write_xdr_ext.rb} +2 -2
- data/test/perl_output/chart_data_labels.xlsx +0 -0
- data/test/perl_output/ignore_errors.xlsx +0 -0
- data/test/regression/test_array_formula04.rb +31 -0
- data/test/regression/test_chart_crossing01.rb +1 -1
- data/test/regression/test_chart_crossing05.rb +46 -0
- data/test/regression/test_chart_crossing06.rb +46 -0
- data/test/regression/test_chart_data_labels26.rb +44 -0
- data/test/regression/test_chart_data_labels27.rb +44 -0
- data/test/regression/test_chart_data_labels28.rb +52 -0
- data/test/regression/test_chart_data_labels29.rb +43 -0
- data/test/regression/test_chart_data_labels30.rb +46 -0
- data/test/regression/test_chart_data_labels31.rb +49 -0
- data/test/regression/test_chart_data_labels32.rb +54 -0
- data/test/regression/test_chart_data_labels33.rb +52 -0
- data/test/regression/test_chart_data_labels34.rb +54 -0
- data/test/regression/test_chart_data_labels35.rb +46 -0
- data/test/regression/test_chart_data_labels36.rb +54 -0
- data/test/regression/test_chart_data_labels37.rb +51 -0
- data/test/regression/test_chart_data_labels38.rb +54 -0
- data/test/regression/test_chart_data_labels39.rb +53 -0
- data/test/regression/test_chart_data_labels40.rb +53 -0
- data/test/regression/test_chart_data_labels41.rb +54 -0
- data/test/regression/test_chart_data_labels42.rb +58 -0
- data/test/regression/test_chart_data_labels43.rb +58 -0
- data/test/regression/test_chart_data_labels44.rb +56 -0
- data/test/regression/test_chart_data_labels45.rb +57 -0
- data/test/regression/test_chart_data_labels46.rb +61 -0
- data/test/regression/test_chart_data_labels47.rb +61 -0
- data/test/regression/test_chart_data_labels48.rb +55 -0
- data/test/regression/test_chart_data_labels49.rb +55 -0
- data/test/regression/test_chart_data_labels50.rb +57 -0
- data/test/regression/test_format16.rb +24 -0
- data/test/regression/test_format17.rb +24 -0
- data/test/regression/test_header04.rb +30 -0
- data/test/regression/test_hyperlink50.rb +27 -0
- data/test/regression/test_hyperlink51.rb +27 -0
- data/test/regression/test_ignore_error01.rb +23 -0
- data/test/regression/test_ignore_error02.rb +24 -0
- data/test/regression/test_ignore_error03.rb +26 -0
- data/test/regression/test_ignore_error04.rb +26 -0
- data/test/regression/test_ignore_error05.rb +32 -0
- data/test/regression/test_ignore_error06.rb +32 -0
- data/test/regression/test_image52.rb +26 -0
- data/test/regression/test_image53.rb +26 -0
- data/test/regression/test_image54.rb +26 -0
- data/test/regression/test_image55.rb +27 -0
- data/test/regression/test_protect04.rb +32 -0
- data/test/regression/test_protect05.rb +35 -0
- data/test/regression/test_protect06.rb +35 -0
- data/test/regression/test_protect07.rb +23 -0
- data/test/regression/test_table26.rb +38 -0
- data/test/regression/xlsx_files/array_formula04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_crossing05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_crossing06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels30.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels31.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels32.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels33.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels34.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels35.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels36.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels37.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels38.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels39.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels40.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels41.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels42.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels43.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels44.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels45.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels46.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels47.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels48.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels49.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels50.xlsx +0 -0
- data/test/regression/xlsx_files/format16.xlsx +0 -0
- data/test/regression/xlsx_files/format17.xlsx +0 -0
- data/test/regression/xlsx_files/header04.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink50.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink51.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error01.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error02.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error03.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error04.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error05.xlsx +0 -0
- data/test/regression/xlsx_files/ignore_error06.xlsx +0 -0
- data/test/regression/xlsx_files/image52.xlsx +0 -0
- data/test/regression/xlsx_files/image53.xlsx +0 -0
- data/test/regression/xlsx_files/image54.xlsx +0 -0
- data/test/regression/xlsx_files/image55.xlsx +0 -0
- data/test/regression/xlsx_files/protect04.xlsx +0 -0
- data/test/regression/xlsx_files/protect05.xlsx +0 -0
- data/test/regression/xlsx_files/protect06.xlsx +0 -0
- data/test/regression/xlsx_files/protect07.xlsx +0 -0
- data/test/regression/xlsx_files/table26.xlsx +0 -0
- data/test/test_example_match.rb +345 -1
- data/test/utility/test_range.rb +20 -0
- metadata +209 -8
data/test/test_example_match.rb
CHANGED
@@ -242,6 +242,319 @@ class TestExampleMatch < Minitest::Test
|
|
242
242
|
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
243
243
|
end
|
244
244
|
|
245
|
+
def test_chart_data_labels
|
246
|
+
@xlsx = 'chart_data_labels.xlsx'
|
247
|
+
workbook = WriteXLSX.new(@io)
|
248
|
+
|
249
|
+
worksheet = workbook.add_worksheet
|
250
|
+
bold = workbook.add_format(:bold => 1)
|
251
|
+
|
252
|
+
# Add the worksheet data that the charts will refer to.
|
253
|
+
headings = ['Number', 'Data', 'Text']
|
254
|
+
data = [
|
255
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
256
|
+
[20, 10, 20, 30, 40, 30 ],
|
257
|
+
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
|
258
|
+
]
|
259
|
+
|
260
|
+
worksheet.write('A1', headings, bold)
|
261
|
+
worksheet.write('A2', data)
|
262
|
+
|
263
|
+
|
264
|
+
#######################################################################
|
265
|
+
#
|
266
|
+
# Example with standard data labels.
|
267
|
+
#
|
268
|
+
|
269
|
+
# Create a Column chart.
|
270
|
+
chart1 = workbook.add_chart(:type => 'column', :embedded => 1)
|
271
|
+
|
272
|
+
# Configure the data series and add the data labels.
|
273
|
+
chart1.add_series(
|
274
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
275
|
+
:values => '=Sheet1!$B$2:$B$7',
|
276
|
+
:data_labels => { :value => 1 }
|
277
|
+
)
|
278
|
+
|
279
|
+
# Add a chart title.
|
280
|
+
chart1.set_title(:name => 'Chart with standard data labels')
|
281
|
+
|
282
|
+
# Turn off the chart legend.
|
283
|
+
chart1.set_legend(:none => 1)
|
284
|
+
|
285
|
+
# Insert the chart into the worksheet (with an offset).
|
286
|
+
worksheet.insert_chart('D2', chart1, { :x_offset => 25, :y_offset => 10 })
|
287
|
+
|
288
|
+
|
289
|
+
#######################################################################
|
290
|
+
#
|
291
|
+
# Example with value and category data labels.
|
292
|
+
#
|
293
|
+
|
294
|
+
# Create a Column chart.
|
295
|
+
chart2 = workbook.add_chart(:type => 'column', :embedded => 1)
|
296
|
+
|
297
|
+
# Configure the data series and add the data labels.
|
298
|
+
chart2.add_series(
|
299
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
300
|
+
:values => '=Sheet1!$B$2:$B$7',
|
301
|
+
:data_labels => { :value => 1, :category => 1 }
|
302
|
+
)
|
303
|
+
|
304
|
+
# Add a chart title.
|
305
|
+
chart2.set_title(:name => 'Category and Value data labels')
|
306
|
+
|
307
|
+
# Turn off the chart legend.
|
308
|
+
chart2.set_legend(:none => 1)
|
309
|
+
|
310
|
+
# Insert the chart into the worksheet (with an offset).
|
311
|
+
worksheet.insert_chart('D18', chart2, { :x_offset => 25, :y_offset => 10 })
|
312
|
+
|
313
|
+
|
314
|
+
#######################################################################
|
315
|
+
#
|
316
|
+
# Example with standard data labels with different font.
|
317
|
+
#
|
318
|
+
|
319
|
+
# Create a Column chart.
|
320
|
+
chart3 = workbook.add_chart(:type => 'column', :embedded => 1)
|
321
|
+
|
322
|
+
# Configure the data series and add the data labels.
|
323
|
+
chart3.add_series(
|
324
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
325
|
+
:values => '=Sheet1!$B$2:$B$7',
|
326
|
+
:data_labels => { :value => 1,
|
327
|
+
:font => {:bold => 1,
|
328
|
+
:color => 'red',
|
329
|
+
:rotation => -30}
|
330
|
+
}
|
331
|
+
)
|
332
|
+
|
333
|
+
# Add a chart title.
|
334
|
+
chart3.set_title(:name => 'Data labels with user defined font')
|
335
|
+
|
336
|
+
# Turn off the chart legend.
|
337
|
+
chart3.set_legend(:none => 1)
|
338
|
+
|
339
|
+
# Insert the chart into the worksheet (with an offset).
|
340
|
+
worksheet.insert_chart('D34', chart3, { :x_offset => 25, :y_offset => 10 })
|
341
|
+
|
342
|
+
|
343
|
+
#######################################################################
|
344
|
+
#
|
345
|
+
# Example with custom string data labels.
|
346
|
+
#
|
347
|
+
|
348
|
+
# Create a Column chart.
|
349
|
+
chart4 = workbook.add_chart(:type => 'column', :embedded => 1)
|
350
|
+
|
351
|
+
# Configure the data series and add the data labels.
|
352
|
+
chart4.add_series(
|
353
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
354
|
+
:values => '=Sheet1!$B$2:$B$7',
|
355
|
+
:data_labels => {
|
356
|
+
:value => 1,
|
357
|
+
:border => {:color => 'red'},
|
358
|
+
:fill => {:color => 'yellow'}
|
359
|
+
}
|
360
|
+
)
|
361
|
+
|
362
|
+
# Add a chart title.
|
363
|
+
chart4.set_title(:name => 'Data labels with formatting')
|
364
|
+
|
365
|
+
# Turn off the chart legend.
|
366
|
+
chart4.set_legend(:none => 1)
|
367
|
+
|
368
|
+
# Insert the chart into the worksheet (with an offset).
|
369
|
+
worksheet.insert_chart('D50', chart4, { :x_offset => 25, :y_offset => 10 })
|
370
|
+
|
371
|
+
|
372
|
+
#######################################################################
|
373
|
+
#
|
374
|
+
# Example with custom string data labels.
|
375
|
+
#
|
376
|
+
|
377
|
+
# Create a Column chart.
|
378
|
+
chart5 = workbook.add_chart( :type => 'column', :embedded => 1 )
|
379
|
+
|
380
|
+
# Some custom labels.
|
381
|
+
custom_labels = [
|
382
|
+
{ :value => 'Amy' },
|
383
|
+
{ :value => 'Bea' },
|
384
|
+
{ :value => 'Eva' },
|
385
|
+
{ :value => 'Fay' },
|
386
|
+
{ :value => 'Liv' },
|
387
|
+
{ :value => 'Una' }
|
388
|
+
]
|
389
|
+
|
390
|
+
# Configure the data series and add the data labels.
|
391
|
+
chart5.add_series(
|
392
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
393
|
+
:values => '=Sheet1!$B$2:$B$7',
|
394
|
+
:data_labels => { :value => 1, :custom => custom_labels }
|
395
|
+
)
|
396
|
+
|
397
|
+
# Add a chart title.
|
398
|
+
chart5.set_title(:name => 'Chart with custom string data labels')
|
399
|
+
|
400
|
+
# Turn off the chart legend.
|
401
|
+
chart5.set_legend(:none => 1)
|
402
|
+
|
403
|
+
# Insert the chart into the worksheet (with an offset).
|
404
|
+
worksheet.insert_chart('D66', chart5, { :x_offset => 25, :y_offset => 10 })
|
405
|
+
|
406
|
+
|
407
|
+
#######################################################################
|
408
|
+
#
|
409
|
+
# Example with custom data labels from cells.
|
410
|
+
#
|
411
|
+
|
412
|
+
# Create a Column chart.
|
413
|
+
chart6 = workbook.add_chart(:type => 'column', :embedded => 1)
|
414
|
+
|
415
|
+
# Some custom labels.
|
416
|
+
custom_labels = [
|
417
|
+
{ :value => '=Sheet1!$C$2' },
|
418
|
+
{ :value => '=Sheet1!$C$3' },
|
419
|
+
{ :value => '=Sheet1!$C$4' },
|
420
|
+
{ :value => '=Sheet1!$C$5' },
|
421
|
+
{ :value => '=Sheet1!$C$6' },
|
422
|
+
{ :value => '=Sheet1!$C$7' }
|
423
|
+
]
|
424
|
+
|
425
|
+
|
426
|
+
# Configure the data series and add the data labels.
|
427
|
+
chart6.add_series(
|
428
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
429
|
+
:values => '=Sheet1!$B$2:$B$7',
|
430
|
+
:data_labels => { :value => 1, :custom => custom_labels }
|
431
|
+
)
|
432
|
+
|
433
|
+
# Add a chart title.
|
434
|
+
chart6.set_title(:name => 'Chart with custom data labels from cells')
|
435
|
+
|
436
|
+
# Turn off the chart legend.
|
437
|
+
chart6.set_legend(:none => 1)
|
438
|
+
|
439
|
+
# Insert the chart into the worksheet (with an offset).
|
440
|
+
worksheet.insert_chart('D82', chart6, { :x_offset => 25, :y_offset => 10 })
|
441
|
+
|
442
|
+
|
443
|
+
#######################################################################
|
444
|
+
#
|
445
|
+
# Example with custom and default data labels.
|
446
|
+
#
|
447
|
+
|
448
|
+
# Create a Column chart.
|
449
|
+
chart7 = workbook.add_chart(:type => 'column', :embedded => 1)
|
450
|
+
|
451
|
+
# Some custom labels. The nil items will get the default value.
|
452
|
+
# We also set a font for the custom items as an extra example.
|
453
|
+
custom_labels = [
|
454
|
+
{ :value => '=Sheet1!$C$2', :font => { :color => 'red' } },
|
455
|
+
nil,
|
456
|
+
{ :value => '=Sheet1!$C$4', :font => { :color => 'red' } },
|
457
|
+
{ :value => '=Sheet1!$C$5', :font => { :color => 'red' } }
|
458
|
+
]
|
459
|
+
|
460
|
+
|
461
|
+
# Configure the data series and add the data labels.
|
462
|
+
chart7.add_series(
|
463
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
464
|
+
:values => '=Sheet1!$B$2:$B$7',
|
465
|
+
:data_labels => { :value => 1, :custom => custom_labels }
|
466
|
+
)
|
467
|
+
|
468
|
+
# Add a chart title.
|
469
|
+
chart7.set_title(:name => 'Mixed custom and default data labels')
|
470
|
+
|
471
|
+
# Turn off the chart legend.
|
472
|
+
chart7.set_legend(:none => 1)
|
473
|
+
|
474
|
+
# Insert the chart into the worksheet (with an offset).
|
475
|
+
worksheet.insert_chart('D98', chart7, { :x_offset => 25, :y_offset => 10 })
|
476
|
+
|
477
|
+
|
478
|
+
#######################################################################
|
479
|
+
#
|
480
|
+
# Example with deleted custom data labels.
|
481
|
+
#
|
482
|
+
|
483
|
+
# Create a Column chart.
|
484
|
+
chart8 = workbook.add_chart(:type => 'column', :embedded => 1)
|
485
|
+
|
486
|
+
# Some deleted custom labels and defaults (nil). This allows us to
|
487
|
+
# highlight certain values such as the minimum and maximum.
|
488
|
+
custom_labels = [
|
489
|
+
{ :delete => 1 },
|
490
|
+
nil,
|
491
|
+
{ :delete => 1 },
|
492
|
+
{ :delete => 1 },
|
493
|
+
nil,
|
494
|
+
{ :delete => 1 }
|
495
|
+
]
|
496
|
+
|
497
|
+
# Configure the data series and add the data labels.
|
498
|
+
chart8.add_series(
|
499
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
500
|
+
:values => '=Sheet1!$B$2:$B$7',
|
501
|
+
:data_labels => { :value => 1, :custom => custom_labels }
|
502
|
+
)
|
503
|
+
|
504
|
+
# Add a chart title.
|
505
|
+
chart8.set_title(:name => 'Chart with deleted data labels')
|
506
|
+
|
507
|
+
# Turn off the chart legend.
|
508
|
+
chart8.set_legend(:none => 1)
|
509
|
+
|
510
|
+
# Insert the chart into the worksheet (with an offset).
|
511
|
+
worksheet.insert_chart('D114', chart8, { :x_offset => 25, :y_offset => 10 })
|
512
|
+
|
513
|
+
#######################################################################
|
514
|
+
#
|
515
|
+
# Example with custom string data labels and formatting.
|
516
|
+
#
|
517
|
+
|
518
|
+
# Create a Column chart.
|
519
|
+
chart9 = workbook.add_chart( :type => 'column', :embedded => 1 )
|
520
|
+
|
521
|
+
# Some custom labels.
|
522
|
+
custom_labels = [
|
523
|
+
{ :value => 'Amy', :border => {:color => 'blue'} },
|
524
|
+
{ :value => 'Bea' },
|
525
|
+
{ :value => 'Eva' },
|
526
|
+
{ :value => 'Fay' },
|
527
|
+
{ :value => 'Liv' },
|
528
|
+
{ :value => 'Una', :fill => {:color => 'green'} }
|
529
|
+
]
|
530
|
+
|
531
|
+
|
532
|
+
# Configure the data series and add the data labels.
|
533
|
+
chart9.add_series(
|
534
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
535
|
+
:values => '=Sheet1!$B$2:$B$7',
|
536
|
+
:data_labels => {
|
537
|
+
:value => 1,
|
538
|
+
:custom => custom_labels,
|
539
|
+
:border => {:color => 'red'},
|
540
|
+
:fill => {:color => 'yellow'}
|
541
|
+
}
|
542
|
+
)
|
543
|
+
|
544
|
+
# Add a chart title.
|
545
|
+
chart9.set_title( :name => 'Chart with custom labels and formatting' )
|
546
|
+
|
547
|
+
# Turn off the chart legend.
|
548
|
+
chart9.set_legend( :none => 1 )
|
549
|
+
|
550
|
+
# Insert the chart into the worksheet (with an offset).
|
551
|
+
worksheet.insert_chart( 'D130', chart9, { :x_offset => 25, :y_offset => 10 } )
|
552
|
+
|
553
|
+
workbook.close
|
554
|
+
store_to_tempfile
|
555
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
556
|
+
end
|
557
|
+
|
245
558
|
def test_chart_gauge
|
246
559
|
@xlsx = 'chart_gauge.xlsx'
|
247
560
|
workbook = WriteXLSX.new(@io)
|
@@ -577,7 +890,7 @@ EOS
|
|
577
890
|
:name => 'Doughnut sales data',
|
578
891
|
:categories => [ 'Sheet1', 1, 3, 0, 0 ],
|
579
892
|
:values => [ 'Sheet1', 1, 3, 1, 1 ]
|
580
|
-
)
|
893
|
+
)
|
581
894
|
|
582
895
|
# Add a title.
|
583
896
|
chart1.set_title(:name => 'Popular Doughnut Types')
|
@@ -2979,6 +3292,37 @@ EOS
|
|
2979
3292
|
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
2980
3293
|
end
|
2981
3294
|
|
3295
|
+
def test_ignore_errors
|
3296
|
+
@xlsx = 'ignore_errors.xlsx'
|
3297
|
+
workbook = WriteXLSX.new(@io)
|
3298
|
+
worksheet = workbook.add_worksheet
|
3299
|
+
|
3300
|
+
# Write strings that looks like numbers. This will cause an Excel warning.
|
3301
|
+
worksheet.write_string('C2', '123')
|
3302
|
+
worksheet.write_string('C3', '123')
|
3303
|
+
|
3304
|
+
# Write a divide by zero formula. This will also cause an Excel warning.
|
3305
|
+
worksheet.write_formula('C5', '=1/0')
|
3306
|
+
worksheet.write_formula('C6', '=1/0')
|
3307
|
+
|
3308
|
+
# Turn off some of the warnings:
|
3309
|
+
worksheet.ignore_errors(
|
3310
|
+
:number_stored_as_text => 'C3',
|
3311
|
+
:eval_error => 'C6'
|
3312
|
+
)
|
3313
|
+
|
3314
|
+
# Write some descriptions for the cells and make the column wider for clarity.
|
3315
|
+
worksheet.set_column('B:B', 16)
|
3316
|
+
worksheet.write('B2', 'Warning:')
|
3317
|
+
worksheet.write('B3', 'Warning turned off:')
|
3318
|
+
worksheet.write('B5', 'Warning:')
|
3319
|
+
worksheet.write('B6', 'Warning turned off:')
|
3320
|
+
|
3321
|
+
workbook.close
|
3322
|
+
store_to_tempfile
|
3323
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @tempfile.path)
|
3324
|
+
end
|
3325
|
+
|
2982
3326
|
def test_merge1
|
2983
3327
|
@xlsx = 'merge1.xlsx'
|
2984
3328
|
# Create a new workbook and add a worksheet
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRange < Minitest::Test
|
5
|
+
include Writexlsx::Utility
|
6
|
+
|
7
|
+
def test_range_0_0_1_1
|
8
|
+
assert_equal(
|
9
|
+
'B1',
|
10
|
+
xl_range(0, 0, 1, 1)
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_range_0_0_1_1_1_1_1_1
|
15
|
+
assert_equal(
|
16
|
+
'$B$1',
|
17
|
+
xl_range(0, 0, 1, 1, 1, 1, 1, 1)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|