write_xlsx 0.62.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +14 -1
- data/examples/chart_data_tools.rb +215 -0
- data/examples/chart_pie.rb +36 -5
- data/examples/sparklines2.rb +1 -1
- data/examples/tab_colors.rb +3 -3
- data/lib/write_xlsx/chart.rb +559 -516
- data/lib/write_xlsx/chart/area.rb +4 -1
- data/lib/write_xlsx/chart/axis.rb +132 -0
- data/lib/write_xlsx/chart/bar.rb +17 -9
- data/lib/write_xlsx/chart/column.rb +9 -1
- data/lib/write_xlsx/chart/line.rb +24 -0
- data/lib/write_xlsx/chart/radar.rb +2 -2
- data/lib/write_xlsx/chart/scatter.rb +19 -0
- data/lib/write_xlsx/chart/stock.rb +10 -3
- data/lib/write_xlsx/drawing.rb +43 -44
- data/lib/write_xlsx/package/vml.rb +21 -14
- data/lib/write_xlsx/shape.rb +173 -22
- data/lib/write_xlsx/sparkline.rb +524 -0
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +183 -115
- data/lib/write_xlsx/worksheet.rb +821 -1073
- data/lib/write_xlsx/worksheet/cell_data.rb +132 -0
- data/lib/write_xlsx/worksheet/print_style.rb +51 -0
- data/test/chart/test_add_series.rb +31 -6
- data/test/chart/test_write_d_lbls.rb +18 -18
- data/test/chart/test_write_number_format.rb +20 -24
- data/test/drawing/test_drawing_shape_01.rb +1 -1
- data/test/drawing/test_drawing_shape_02.rb +2 -2
- data/test/drawing/test_drawing_shape_03.rb +5 -5
- data/test/drawing/test_drawing_shape_04.rb +3 -3
- data/test/drawing/test_drawing_shape_05.rb +4 -4
- data/test/drawing/test_drawing_shape_07.rb +2 -2
- data/test/perl_output/chart_data_tools.xlsx +0 -0
- data/test/perl_output/chart_pie.xlsx +0 -0
- data/test/regression/disabled_test_vml04.rb +2 -2
- data/test/regression/test_chart_drop_lines01.rb +46 -0
- data/test/regression/test_chart_drop_lines02.rb +51 -0
- data/test/regression/test_chart_drop_lines03.rb +46 -0
- data/test/regression/test_chart_drop_lines04.rb +64 -0
- data/test/regression/test_chart_errorbars01.rb +47 -0
- data/test/regression/test_chart_errorbars02.rb +57 -0
- data/test/regression/test_chart_errorbars03.rb +53 -0
- data/test/regression/test_chart_errorbars04.rb +48 -0
- data/test/regression/test_chart_errorbars05.rb +47 -0
- data/test/regression/test_chart_errorbars06.rb +47 -0
- data/test/regression/test_chart_errorbars07.rb +66 -0
- data/test/regression/test_chart_font02.rb +1 -1
- data/test/regression/test_chart_font06.rb +1 -1
- data/test/regression/test_chart_gridlines04.rb +2 -1
- data/test/regression/test_chart_gridlines08.rb +2 -1
- data/test/regression/test_chart_points01.rb +37 -0
- data/test/regression/test_chart_points02.rb +40 -0
- data/test/regression/test_chart_points03.rb +42 -0
- data/test/regression/test_chart_points04.rb +52 -0
- data/test/regression/test_chart_points05.rb +49 -0
- data/test/regression/test_chart_points06.rb +49 -0
- data/test/regression/test_chartsheet05.rb +1 -1
- data/test/regression/test_chartsheet06.rb +1 -1
- data/test/regression/test_comment01.rb +1 -1
- data/test/regression/test_comment02.rb +1 -1
- data/test/regression/test_comment03.rb +1 -1
- data/test/regression/test_comment04.rb +2 -2
- data/test/regression/test_comment06.rb +1 -1
- data/test/regression/test_comment07.rb +1 -1
- data/test/regression/test_comment08.rb +1 -1
- data/test/regression/test_comment09.rb +1 -1
- data/test/regression/test_comment10.rb +1 -1
- data/test/regression/test_default_row04.rb +1 -1
- data/test/regression/test_escapes02.rb +1 -1
- data/test/regression/test_hyperlink15.rb +2 -2
- data/test/regression/test_shape_connect01.rb +6 -6
- data/test/regression/test_shape_connect02.rb +6 -6
- data/test/regression/test_shape_connect03.rb +11 -11
- data/test/regression/test_shape_connect04.rb +10 -10
- data/test/regression/test_shape_scale01.rb +2 -2
- data/test/regression/test_shape_stencil01.rb +3 -3
- data/test/regression/test_tab_color01.rb +1 -1
- data/test/regression/test_table04.rb +1 -1
- data/test/regression/test_table05.rb +1 -1
- data/test/regression/test_table06.rb +1 -1
- data/test/regression/test_vml01.rb +1 -1
- data/test/regression/test_vml02.rb +1 -1
- data/test/regression/test_vml03.rb +2 -2
- data/test/regression/xlsx_files/chart_drop_lines01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_drop_lines02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_drop_lines03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_drop_lines04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_errorbars07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_points06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_stock02.xlsx +0 -0
- data/test/test_example_match.rb +278 -57
- data/test/worksheet/test_convert_date_time_02.rb +427 -433
- data/test/worksheet/test_convert_date_time_03.rb +1 -1
- data/test/worksheet/test_write_sheet_pr.rb +2 -2
- data/test/worksheet/test_write_sheet_view1.rb +2 -2
- metadata +80 -10
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/test/test_example_match.rb
CHANGED
|
@@ -541,32 +541,58 @@ def test_chart_pie
|
|
|
541
541
|
# Add the worksheet data that the charts will refer to.
|
|
542
542
|
headings = [ 'Category', 'Values' ]
|
|
543
543
|
data = [
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
544
|
+
[ 'Apple', 'Cherry', 'Pecan' ],
|
|
545
|
+
[ 60, 30, 10 ]
|
|
546
|
+
]
|
|
547
547
|
|
|
548
548
|
worksheet.write('A1', headings, bold)
|
|
549
549
|
worksheet.write('A2', data)
|
|
550
550
|
|
|
551
551
|
# Create a new chart object. In this case an embedded chart.
|
|
552
|
-
|
|
552
|
+
chart1 = workbook.add_chart(:type => 'pie', :embedded => 1)
|
|
553
553
|
|
|
554
554
|
# Configure the series. Note the use of the array ref to define ranges:
|
|
555
555
|
# [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
556
|
+
# See below for an alternative syntax.
|
|
557
|
+
chart1.add_series(
|
|
558
|
+
:name => 'Pie sales data',
|
|
559
|
+
:categories => [ 'Sheet1', 1, 3, 0, 0 ],
|
|
560
|
+
:values => [ 'Sheet1', 1, 3, 1, 1 ]
|
|
561
|
+
)
|
|
561
562
|
|
|
562
563
|
# Add a title.
|
|
563
|
-
|
|
564
|
+
chart1.set_title(:name => 'Popular Pie Types')
|
|
564
565
|
|
|
565
566
|
# Set an Excel chart style. Blue colors with white outline and shadow.
|
|
566
|
-
|
|
567
|
+
chart1.set_style(10)
|
|
567
568
|
|
|
568
569
|
# Insert the chart into the worksheet (with an offset).
|
|
569
|
-
worksheet.insert_chart('C2',
|
|
570
|
+
worksheet.insert_chart('C2', chart1, 25, 10)
|
|
571
|
+
|
|
572
|
+
#
|
|
573
|
+
# Create a Pie chart with user defined segment colors.
|
|
574
|
+
#
|
|
575
|
+
|
|
576
|
+
# Create an example Pie chart like above.
|
|
577
|
+
chart2 = workbook.add_chart(:type => 'pie', :embedded => 1)
|
|
578
|
+
|
|
579
|
+
# Configure the series and add user defined segment colours.
|
|
580
|
+
chart2.add_series(
|
|
581
|
+
:name => 'Pie sales data',
|
|
582
|
+
:categories => '=Sheet1!$A$2:$A$4',
|
|
583
|
+
:values => '=Sheet1!$B$2:$B$4',
|
|
584
|
+
:points => [
|
|
585
|
+
{ :fill => { :color => '#5ABA10' } },
|
|
586
|
+
{ :fill => { :color => '#FE110E' } },
|
|
587
|
+
{ :fill => { :color => '#CA5C05' } }
|
|
588
|
+
]
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
# Add a title.
|
|
592
|
+
chart2.set_title(:name => 'Pie Chart with user defined colors')
|
|
593
|
+
|
|
594
|
+
worksheet.insert_chart('C18', chart2, 25, 10)
|
|
595
|
+
|
|
570
596
|
|
|
571
597
|
workbook.close
|
|
572
598
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
@@ -3389,8 +3415,8 @@ def test_shape3
|
|
|
3389
3415
|
)
|
|
3390
3416
|
|
|
3391
3417
|
worksheet.insert_shape('A1', normal, 50, 50)
|
|
3392
|
-
normal
|
|
3393
|
-
normal
|
|
3418
|
+
normal.text = 'Scaled 3w x 2h'
|
|
3419
|
+
normal.name = 'Hope'
|
|
3394
3420
|
worksheet.insert_shape('A1', normal, 250, 50, 3, 2)
|
|
3395
3421
|
|
|
3396
3422
|
workbook.close
|
|
@@ -3408,14 +3434,14 @@ def test_shape4
|
|
|
3408
3434
|
:type => type,
|
|
3409
3435
|
:width => 90,
|
|
3410
3436
|
:height => 90
|
|
3411
|
-
|
|
3437
|
+
)
|
|
3412
3438
|
|
|
3413
3439
|
(1..10).each do |n|
|
|
3414
3440
|
# Change the last 5 rectangles to stars. Previously
|
|
3415
3441
|
# inserted shapes stay as rectangles.
|
|
3416
3442
|
type = 'star5' if n == 6
|
|
3417
|
-
shape
|
|
3418
|
-
shape
|
|
3443
|
+
shape.type = type
|
|
3444
|
+
shape.text = "#{type} #{n}"
|
|
3419
3445
|
worksheet.insert_shape('A1', shape, n * 100, 50)
|
|
3420
3446
|
end
|
|
3421
3447
|
|
|
@@ -3427,15 +3453,15 @@ def test_shape4
|
|
|
3427
3453
|
)
|
|
3428
3454
|
worksheet.insert_shape('A1', stencil, 100, 150)
|
|
3429
3455
|
|
|
3430
|
-
stencil
|
|
3456
|
+
stencil.stencil = 0
|
|
3431
3457
|
worksheet.insert_shape('A1', stencil, 200, 150)
|
|
3432
3458
|
worksheet.insert_shape('A1', stencil, 300, 150)
|
|
3433
3459
|
|
|
3434
3460
|
# Ooopa! Changed my mind.
|
|
3435
3461
|
# Change the rectangle to an ellipse (circle),
|
|
3436
3462
|
# for the last two shapes.
|
|
3437
|
-
stencil
|
|
3438
|
-
stencil
|
|
3463
|
+
stencil.type = 'ellipse'
|
|
3464
|
+
stencil.text = 'Now its a circle'
|
|
3439
3465
|
|
|
3440
3466
|
workbook.close
|
|
3441
3467
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
@@ -3464,14 +3490,14 @@ def test_shape5
|
|
|
3464
3490
|
cxn_shape = workbook.add_shape(:type => 'bentConnector3')
|
|
3465
3491
|
|
|
3466
3492
|
# Link the start of the connector to the right side.
|
|
3467
|
-
cxn_shape
|
|
3468
|
-
cxn_shape
|
|
3469
|
-
cxn_shape
|
|
3493
|
+
cxn_shape.start = s1.id
|
|
3494
|
+
cxn_shape.start_index = 4 # 4th connection pt, clockwise from top(0).
|
|
3495
|
+
cxn_shape.start_side = 'b' # r)ight or b)ottom.
|
|
3470
3496
|
|
|
3471
3497
|
# Link the end of the connector to the left side.
|
|
3472
|
-
cxn_shape
|
|
3473
|
-
cxn_shape
|
|
3474
|
-
cxn_shape
|
|
3498
|
+
cxn_shape.end = s2.id
|
|
3499
|
+
cxn_shape.end_index = 0 # clockwise from top(0).
|
|
3500
|
+
cxn_shape.end_side = 't' # t)op.
|
|
3475
3501
|
|
|
3476
3502
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3477
3503
|
|
|
@@ -3502,14 +3528,14 @@ def test_shape6
|
|
|
3502
3528
|
cxn_shape = workbook.add_shape(:type => 'curvedConnector3')
|
|
3503
3529
|
|
|
3504
3530
|
# Link the start of the connector to the right side.
|
|
3505
|
-
cxn_shape
|
|
3506
|
-
cxn_shape
|
|
3507
|
-
cxn_shape
|
|
3531
|
+
cxn_shape.start = s1.id
|
|
3532
|
+
cxn_shape.start_index = 2 # 2nd connection pt, clockwise from top(0).
|
|
3533
|
+
cxn_shape.start_side = 'r' # r)ight or b)ottom.
|
|
3508
3534
|
|
|
3509
3535
|
# Link the end of the connector to the left side.
|
|
3510
|
-
cxn_shape
|
|
3511
|
-
cxn_shape
|
|
3512
|
-
cxn_shape
|
|
3536
|
+
cxn_shape.end = s2.id
|
|
3537
|
+
cxn_shape.end_index = 4 # 4th connection pt, clockwise from top(0).
|
|
3538
|
+
cxn_shape.end_side = 'l' # l)eft or t)op.
|
|
3513
3539
|
|
|
3514
3540
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3515
3541
|
|
|
@@ -3553,28 +3579,28 @@ def test_shape7
|
|
|
3553
3579
|
p1 = worksheet.insert_shape('A1', plus, 350, 350)
|
|
3554
3580
|
p2 = worksheet.insert_shape('A1', plus, 150, 350)
|
|
3555
3581
|
p3 = worksheet.insert_shape('A1', plus, 350, 150)
|
|
3556
|
-
plus
|
|
3582
|
+
plus.adjustments = 35 # change shape of plus symbol.
|
|
3557
3583
|
p4 = worksheet.insert_shape('A1', plus, 150, 150)
|
|
3558
3584
|
|
|
3559
3585
|
cxn_shape = workbook.add_shape(:type => 'bentConnector3', :fill => 0)
|
|
3560
3586
|
|
|
3561
|
-
cxn_shape
|
|
3562
|
-
cxn_shape
|
|
3563
|
-
cxn_shape
|
|
3587
|
+
cxn_shape.start = ellipse.id
|
|
3588
|
+
cxn_shape.start_index = 4 # 4th connection pt, clockwise from top(0).
|
|
3589
|
+
cxn_shape.start_side = 'b' # r)ight or b)ottom.
|
|
3564
3590
|
|
|
3565
|
-
cxn_shape
|
|
3566
|
-
cxn_shape
|
|
3567
|
-
cxn_shape
|
|
3591
|
+
cxn_shape.end = p1.id
|
|
3592
|
+
cxn_shape.end_index = 0
|
|
3593
|
+
cxn_shape.end_side = 't' # l)eft or t)op.
|
|
3568
3594
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3569
3595
|
|
|
3570
|
-
cxn_shape
|
|
3596
|
+
cxn_shape.end = p2.id
|
|
3571
3597
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3572
3598
|
|
|
3573
|
-
cxn_shape
|
|
3599
|
+
cxn_shape.end = p3.id
|
|
3574
3600
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3575
3601
|
|
|
3576
|
-
cxn_shape
|
|
3577
|
-
cxn_shape
|
|
3602
|
+
cxn_shape.end = p4.id
|
|
3603
|
+
cxn_shape.adjustments = [-50, 45, 120]
|
|
3578
3604
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3579
3605
|
|
|
3580
3606
|
workbook.close
|
|
@@ -3621,23 +3647,23 @@ def test_shape8
|
|
|
3621
3647
|
|
|
3622
3648
|
cxn_shape = workbook.add_shape(:type => 'bentConnector3', :fill => 0)
|
|
3623
3649
|
|
|
3624
|
-
cxn_shape
|
|
3625
|
-
cxn_shape
|
|
3626
|
-
cxn_shape
|
|
3650
|
+
cxn_shape.start = ellipse.id
|
|
3651
|
+
cxn_shape.start_index = 2 # 2nd connection pt, clockwise from top(0).
|
|
3652
|
+
cxn_shape.start_side = 'r' # r)ight or b)ottom.
|
|
3627
3653
|
|
|
3628
|
-
cxn_shape
|
|
3629
|
-
cxn_shape
|
|
3630
|
-
cxn_shape
|
|
3654
|
+
cxn_shape.end = p1.id
|
|
3655
|
+
cxn_shape.end_index = 3 # 3rd connection point on plus, right side
|
|
3656
|
+
cxn_shape.end_side = 'l' # l)eft or t)op.
|
|
3631
3657
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3632
3658
|
|
|
3633
|
-
cxn_shape
|
|
3659
|
+
cxn_shape.end = p2.id
|
|
3634
3660
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3635
3661
|
|
|
3636
|
-
cxn_shape
|
|
3662
|
+
cxn_shape.end = p3.id
|
|
3637
3663
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3638
3664
|
|
|
3639
|
-
cxn_shape
|
|
3640
|
-
cxn_shape
|
|
3665
|
+
cxn_shape.end = p4.id
|
|
3666
|
+
cxn_shape.adjustments = [-50, 45, 120]
|
|
3641
3667
|
worksheet.insert_shape('A1', cxn_shape, 0, 0)
|
|
3642
3668
|
|
|
3643
3669
|
workbook.close
|
|
@@ -4064,9 +4090,9 @@ def test_tab_colors
|
|
|
4064
4090
|
worksheet4 = workbook.add_worksheet
|
|
4065
4091
|
|
|
4066
4092
|
# Worksheet1 will have the default tab colour.
|
|
4067
|
-
worksheet2.
|
|
4068
|
-
worksheet3.
|
|
4069
|
-
worksheet4.
|
|
4093
|
+
worksheet2.tab_color = 'red'
|
|
4094
|
+
worksheet3.tab_color = 'green'
|
|
4095
|
+
worksheet4.tab_color = 0x35 # Orange
|
|
4070
4096
|
|
|
4071
4097
|
workbook.close
|
|
4072
4098
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
@@ -4472,7 +4498,7 @@ def test_sparklines2
|
|
|
4472
4498
|
# Set the columns widths to make the output clearer.
|
|
4473
4499
|
worksheet1.set_column('A:A', 14)
|
|
4474
4500
|
worksheet1.set_column('B:B', 50)
|
|
4475
|
-
worksheet1.
|
|
4501
|
+
worksheet1.zoom = 150
|
|
4476
4502
|
|
|
4477
4503
|
# Headings.
|
|
4478
4504
|
worksheet1.write('A1', 'Sparkline', bold)
|
|
@@ -4965,4 +4991,199 @@ def test_chart_data_table
|
|
|
4965
4991
|
workbook.close
|
|
4966
4992
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
4967
4993
|
end
|
|
4994
|
+
|
|
4995
|
+
def test_chart_data_tools
|
|
4996
|
+
@xlsx = 'chart_data_tools.xlsx'
|
|
4997
|
+
workbook = WriteXLSX.new(@xlsx)
|
|
4998
|
+
worksheet = workbook.add_worksheet
|
|
4999
|
+
bold = workbook.add_format(:bold => 1)
|
|
5000
|
+
|
|
5001
|
+
# Add the worksheet data that the charts will refer to.
|
|
5002
|
+
headings = [ 'Number', 'Data 1', 'Data 2' ]
|
|
5003
|
+
data = [
|
|
5004
|
+
[ 2, 3, 4, 5, 6, 7 ],
|
|
5005
|
+
[ 10, 40, 50, 20, 10, 50 ],
|
|
5006
|
+
[ 30, 60, 70, 50, 40, 30 ]
|
|
5007
|
+
]
|
|
5008
|
+
|
|
5009
|
+
worksheet.write('A1', headings, bold)
|
|
5010
|
+
worksheet.write('A2', data)
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
#######################################################################
|
|
5014
|
+
#
|
|
5015
|
+
# Trendline example.
|
|
5016
|
+
#
|
|
5017
|
+
|
|
5018
|
+
# Create a Line chart.
|
|
5019
|
+
chart1 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5020
|
+
|
|
5021
|
+
# Configure the first series with a polynomial trendline.
|
|
5022
|
+
chart1.add_series(
|
|
5023
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5024
|
+
:values => '=Sheet1!$B$2:$B$7',
|
|
5025
|
+
:trendline => {
|
|
5026
|
+
:type => 'polynomial',
|
|
5027
|
+
:order => 3,
|
|
5028
|
+
}
|
|
5029
|
+
)
|
|
5030
|
+
|
|
5031
|
+
# Configure the second series with a moving average trendline.
|
|
5032
|
+
chart1.add_series(
|
|
5033
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5034
|
+
:values => '=Sheet1!$C$2:$C$7',
|
|
5035
|
+
:trendline => { :type => 'linear' }
|
|
5036
|
+
)
|
|
5037
|
+
|
|
5038
|
+
# Add a chart title. and some axis labels.
|
|
5039
|
+
chart1.set_title(:name => 'Chart with Trendlines')
|
|
5040
|
+
|
|
5041
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5042
|
+
worksheet.insert_chart('D2', chart1, 25, 10)
|
|
5043
|
+
|
|
5044
|
+
#######################################################################
|
|
5045
|
+
#
|
|
5046
|
+
# Data Labels and Markers example.
|
|
5047
|
+
#
|
|
5048
|
+
|
|
5049
|
+
# Create a Line chart.
|
|
5050
|
+
chart2 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5051
|
+
|
|
5052
|
+
# Configure the first series.
|
|
5053
|
+
chart2.add_series(
|
|
5054
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5055
|
+
:values => '=Sheet1!$B$2:$B$7',
|
|
5056
|
+
:data_labels => { :value => 1 },
|
|
5057
|
+
:marker => { :type => 'automatic' }
|
|
5058
|
+
)
|
|
5059
|
+
|
|
5060
|
+
# Configure the second series.
|
|
5061
|
+
chart2.add_series(
|
|
5062
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5063
|
+
:values => '=Sheet1!$C$2:$C$7'
|
|
5064
|
+
)
|
|
5065
|
+
|
|
5066
|
+
# Add a chart title. and some axis labels.
|
|
5067
|
+
chart2.set_title(:name => 'Chart with Data Labels and Markers')
|
|
5068
|
+
|
|
5069
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5070
|
+
worksheet.insert_chart('D18', chart2, 25, 10)
|
|
5071
|
+
|
|
5072
|
+
#######################################################################
|
|
5073
|
+
#
|
|
5074
|
+
# Error Bars example.
|
|
5075
|
+
#
|
|
5076
|
+
|
|
5077
|
+
# Create a Line chart.
|
|
5078
|
+
chart3 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5079
|
+
|
|
5080
|
+
# Configure the first series.
|
|
5081
|
+
chart3.add_series(
|
|
5082
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5083
|
+
:values => '=Sheet1!$B$2:$B$7',
|
|
5084
|
+
:y_error_bars => { :type => 'standard_error' }
|
|
5085
|
+
)
|
|
5086
|
+
|
|
5087
|
+
# Configure the second series.
|
|
5088
|
+
chart3.add_series(
|
|
5089
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5090
|
+
:values => '=Sheet1!$C$2:$C$7'
|
|
5091
|
+
)
|
|
5092
|
+
|
|
5093
|
+
# Add a chart title. and some axis labels.
|
|
5094
|
+
chart3.set_title(:name => 'Chart with Error Bars')
|
|
5095
|
+
|
|
5096
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5097
|
+
worksheet.insert_chart('D34', chart3, 25, 10)
|
|
5098
|
+
|
|
5099
|
+
#######################################################################
|
|
5100
|
+
#
|
|
5101
|
+
# Up-Down Bars example.
|
|
5102
|
+
#
|
|
5103
|
+
|
|
5104
|
+
# Create a Line chart.
|
|
5105
|
+
chart4 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5106
|
+
|
|
5107
|
+
# Add the Up-Down Bars.
|
|
5108
|
+
chart4.set_up_down_bars
|
|
5109
|
+
|
|
5110
|
+
# Configure the first series.
|
|
5111
|
+
chart4.add_series(
|
|
5112
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5113
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
5114
|
+
)
|
|
5115
|
+
|
|
5116
|
+
# Configure the second series.
|
|
5117
|
+
chart4.add_series(
|
|
5118
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5119
|
+
:values => '=Sheet1!$C$2:$C$7'
|
|
5120
|
+
)
|
|
5121
|
+
|
|
5122
|
+
# Add a chart title. and some axis labels.
|
|
5123
|
+
chart4.set_title(:name => 'Chart with Up-Down Bars')
|
|
5124
|
+
|
|
5125
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5126
|
+
worksheet.insert_chart('D50', chart4, 25, 10)
|
|
5127
|
+
|
|
5128
|
+
#######################################################################
|
|
5129
|
+
#
|
|
5130
|
+
# High-Low Lines example.
|
|
5131
|
+
#
|
|
5132
|
+
|
|
5133
|
+
# Create a Line chart.
|
|
5134
|
+
chart5 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5135
|
+
|
|
5136
|
+
# Add the High-Low lines.
|
|
5137
|
+
chart5.set_high_low_lines
|
|
5138
|
+
|
|
5139
|
+
# Configure the first series.
|
|
5140
|
+
chart5.add_series(
|
|
5141
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5142
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
5143
|
+
)
|
|
5144
|
+
|
|
5145
|
+
# Configure the second series.
|
|
5146
|
+
chart5.add_series(
|
|
5147
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5148
|
+
:values => '=Sheet1!$C$2:$C$7'
|
|
5149
|
+
)
|
|
5150
|
+
|
|
5151
|
+
# Add a chart title. and some axis labels.
|
|
5152
|
+
chart5.set_title(:name => 'Chart with High-Low Lines')
|
|
5153
|
+
|
|
5154
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5155
|
+
worksheet.insert_chart('D66', chart5, 25, 10)
|
|
5156
|
+
|
|
5157
|
+
#######################################################################
|
|
5158
|
+
#
|
|
5159
|
+
# Drop Lines example.
|
|
5160
|
+
#
|
|
5161
|
+
|
|
5162
|
+
# Create a Line chart.
|
|
5163
|
+
chart6 = workbook.add_chart(:type => 'line', :embedded => 1)
|
|
5164
|
+
|
|
5165
|
+
# Add Drop Lines.
|
|
5166
|
+
chart6.set_drop_lines
|
|
5167
|
+
|
|
5168
|
+
# Configure the first series.
|
|
5169
|
+
chart6.add_series(
|
|
5170
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5171
|
+
:values => '=Sheet1!$B$2:$B$7'
|
|
5172
|
+
)
|
|
5173
|
+
|
|
5174
|
+
# Configure the second series.
|
|
5175
|
+
chart6.add_series(
|
|
5176
|
+
:categories => '=Sheet1!$A$2:$A$7',
|
|
5177
|
+
:values => '=Sheet1!$C$2:$C$7'
|
|
5178
|
+
)
|
|
5179
|
+
|
|
5180
|
+
# Add a chart title. and some axis labels.
|
|
5181
|
+
chart6.set_title(:name => 'Chart with Drop Lines')
|
|
5182
|
+
|
|
5183
|
+
# Insert the chart into the worksheet (with an offset).
|
|
5184
|
+
worksheet.insert_chart('D82', chart6, 25, 10)
|
|
5185
|
+
|
|
5186
|
+
workbook.close
|
|
5187
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
5188
|
+
end
|
|
4968
5189
|
end
|