write_xlsx 0.97.0 → 1.04.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changes +78 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/examples/a_simple.rb +1 -1
- data/examples/add_vba_project.rb +1 -1
- data/examples/array_formula.rb +1 -1
- data/examples/chart_area.rb +5 -2
- data/examples/chart_bar.rb +5 -2
- data/examples/chart_clustered.rb +1 -1
- data/examples/chart_column.rb +5 -2
- data/examples/chart_combined.rb +1 -1
- data/examples/chart_data_table.rb +9 -3
- data/examples/chart_data_tools.rb +25 -7
- data/examples/chart_doughnut.rb +17 -5
- data/examples/chart_gauge.rb +73 -0
- data/examples/chart_line.rb +90 -12
- data/examples/chart_pareto.rb +1 -1
- data/examples/chart_pie.rb +9 -3
- data/examples/chart_radar.rb +13 -4
- data/examples/chart_scatter.rb +5 -2
- data/examples/chart_secondary_axis.rb +5 -2
- data/examples/chart_stock.rb +1 -1
- data/examples/chart_styles.rb +1 -1
- data/examples/colors.rb +1 -1
- data/examples/data_validate.rb +1 -1
- data/examples/date_time.rb +1 -1
- data/examples/demo.rb +4 -1
- data/examples/formats.rb +1 -1
- data/examples/headers.rb +1 -1
- data/examples/hide_row_col.rb +1 -1
- data/examples/hide_sheet.rb +1 -1
- data/examples/hyperlink1.rb +1 -1
- data/examples/indent.rb +1 -1
- data/examples/macros.rb +1 -1
- data/examples/merge1.rb +1 -1
- data/examples/merge2.rb +1 -1
- data/examples/merge3.rb +1 -1
- data/examples/merge4.rb +1 -1
- data/examples/merge5.rb +1 -1
- data/examples/merge6.rb +1 -1
- data/examples/outline.rb +1 -1
- data/examples/outline_collapsed.rb +1 -1
- data/examples/panes.rb +1 -1
- data/examples/properties.rb +1 -1
- data/examples/regions.rb +1 -1
- data/examples/rich_strings.rb +1 -1
- data/examples/right_to_left.rb +1 -1
- data/examples/shape1.rb +1 -1
- data/examples/shape2.rb +1 -1
- data/examples/shape3.rb +1 -1
- data/examples/shape4.rb +1 -1
- data/examples/shape5.rb +1 -1
- data/examples/shape6.rb +1 -1
- data/examples/shape7.rb +1 -1
- data/examples/shape8.rb +1 -1
- data/examples/shape_all.rb +1 -1
- data/examples/sparklines1.rb +1 -1
- data/examples/sparklines2.rb +1 -1
- data/examples/stats.rb +1 -1
- data/examples/stats_ext.rb +1 -1
- data/examples/stocks.rb +1 -1
- data/examples/tab_colors.rb +1 -1
- data/examples/tables.rb +78 -43
- data/lib/write_xlsx/chart.rb +43 -35
- data/lib/write_xlsx/chart/area.rb +1 -1
- data/lib/write_xlsx/chart/axis.rb +2 -2
- data/lib/write_xlsx/chart/bar.rb +1 -1
- data/lib/write_xlsx/chart/column.rb +1 -1
- data/lib/write_xlsx/chart/doughnut.rb +1 -1
- data/lib/write_xlsx/chart/legend.rb +14 -0
- data/lib/write_xlsx/chart/line.rb +16 -2
- data/lib/write_xlsx/chart/pie.rb +30 -15
- data/lib/write_xlsx/chart/radar.rb +1 -1
- data/lib/write_xlsx/chart/scatter.rb +1 -1
- data/lib/write_xlsx/chart/stock.rb +1 -1
- data/lib/write_xlsx/chartsheet.rb +35 -7
- data/lib/write_xlsx/drawing.rb +86 -30
- data/lib/write_xlsx/format.rb +9 -9
- data/lib/write_xlsx/package/comments.rb +61 -58
- data/lib/write_xlsx/package/conditional_format.rb +9 -1
- data/lib/write_xlsx/package/relationships.rb +4 -4
- data/lib/write_xlsx/package/styles.rb +26 -8
- data/lib/write_xlsx/package/table.rb +13 -7
- data/lib/write_xlsx/package/vml.rb +20 -19
- data/lib/write_xlsx/shape.rb +4 -3
- data/lib/write_xlsx/sheets.rb +18 -16
- data/lib/write_xlsx/sparkline.rb +1 -1
- data/lib/write_xlsx/utility.rb +96 -7
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +99 -49
- data/lib/write_xlsx/worksheet.rb +225 -145
- data/lib/write_xlsx/worksheet/data_validation.rb +10 -14
- data/lib/write_xlsx/worksheet/hyperlink.rb +16 -37
- data/test/chart/test_write_legend_pos.rb +9 -1
- data/test/chartsheet/test_write_sheet_protection.rb +91 -0
- data/test/drawing/test_drawing_chart_01.rb +6 -2
- data/test/drawing/test_drawing_image_01.rb +12 -3
- data/test/drawing/test_drawing_shape_01.rb +8 -5
- data/test/drawing/test_drawing_shape_02.rb +12 -5
- data/test/drawing/test_drawing_shape_03.rb +8 -5
- data/test/drawing/test_drawing_shape_04.rb +8 -24
- data/test/drawing/test_drawing_shape_05.rb +8 -5
- data/test/drawing/test_drawing_shape_06.rb +11 -6
- data/test/drawing/test_drawing_shape_07.rb +11 -6
- data/test/drawing/test_write_a_graphic_frame_locks.rb +1 -1
- data/test/drawing/test_write_c_chart.rb +1 -1
- data/test/drawing/test_write_c_nv_graphic_frame_pr.rb +1 -1
- data/test/drawing/test_write_c_nv_pr.rb +1 -1
- data/test/drawing/test_write_col.rb +1 -1
- data/test/drawing/test_write_col_off.rb +1 -1
- data/test/drawing/test_write_ext.rb +1 -1
- data/test/drawing/test_write_pos.rb +1 -1
- data/test/drawing/test_write_row.rb +1 -1
- data/test/drawing/test_write_row_off.rb +1 -1
- data/test/drawing/test_write_xfrm_extension.rb +1 -1
- data/test/drawing/test_write_xfrm_offset.rb +1 -1
- data/test/package/comments/test_comments_01.rb +54 -0
- data/test/package/comments/test_comments_02.rb +54 -0
- data/test/perl_output/chart_gauge.xlsx +0 -0
- data/test/perl_output/chart_line.xlsx +0 -0
- data/test/perl_output/comments2.xlsx +0 -0
- data/test/perl_output/formats.xlsx +0 -0
- data/test/perl_output/tables.xlsx +0 -0
- data/test/regression/images/happy.jpg +0 -0
- data/test/regression/images/red2.png +0 -0
- data/test/regression/test_array_formula03.rb +36 -0
- data/test/regression/test_autofilter08.rb +110 -0
- data/test/regression/test_autofilter09.rb +110 -0
- data/test/regression/test_autofilter10.rb +110 -0
- data/test/regression/test_chart_axis26.rb +10 -8
- data/test/regression/test_chart_axis27.rb +1 -1
- data/test/regression/test_chart_axis28.rb +1 -1
- data/test/regression/test_chart_axis29.rb +1 -1
- data/test/regression/test_chart_axis33.rb +1 -1
- data/test/regression/test_chart_axis42.rb +44 -0
- data/test/regression/test_chart_axis43.rb +44 -0
- data/test/regression/test_chart_axis44.rb +54 -0
- data/test/regression/test_chart_axis45.rb +54 -0
- data/test/regression/test_chart_axis46.rb +54 -0
- data/test/regression/test_chart_combined10.rb +43 -0
- data/test/regression/test_chart_combined11.rb +63 -0
- data/test/regression/test_chart_data_labels25.rb +1 -1
- data/test/regression/test_chart_doughnut07.rb +37 -0
- data/test/regression/test_chart_font09.rb +1 -1
- data/test/regression/test_chart_legend03.rb +41 -0
- data/test/regression/test_chart_legend04.rb +41 -0
- data/test/regression/test_chart_legend05.rb +41 -0
- data/test/regression/test_chart_legend06.rb +41 -0
- data/test/regression/test_chart_legend07.rb +38 -0
- data/test/regression/test_chart_line05.rb +43 -0
- data/test/regression/test_chart_line06.rb +43 -0
- data/test/regression/test_chart_size03.rb +4 -1
- data/test/regression/test_comment13.rb +36 -0
- data/test/regression/test_comment14.rb +29 -0
- data/test/regression/test_comment15.rb +28 -0
- data/test/regression/test_comment16.rb +34 -0
- data/test/regression/test_cond_format19.rb +64 -0
- data/test/regression/test_cond_format20.rb +43 -0
- data/test/regression/test_format15.rb +26 -0
- data/test/regression/test_header_image15.rb +36 -0
- data/test/regression/test_header_image16.rb +42 -0
- data/test/regression/test_header_image17.rb +46 -0
- data/test/regression/test_header_image18.rb +48 -0
- data/test/regression/test_header_image19.rb +36 -0
- data/test/regression/test_hyperlink32.rb +27 -0
- data/test/regression/test_hyperlink33.rb +28 -0
- data/test/regression/test_hyperlink34.rb +33 -0
- data/test/regression/test_hyperlink35.rb +39 -0
- data/test/regression/test_hyperlink36.rb +34 -0
- data/test/regression/test_hyperlink37.rb +33 -0
- data/test/regression/test_hyperlink38.rb +27 -0
- data/test/regression/test_hyperlink39.rb +27 -0
- data/test/regression/test_hyperlink40.rb +27 -0
- data/test/regression/test_hyperlink41.rb +27 -0
- data/test/regression/test_hyperlink42.rb +27 -0
- data/test/regression/test_hyperlink43.rb +27 -0
- data/test/regression/test_hyperlink44.rb +27 -0
- data/test/regression/test_hyperlink45.rb +27 -0
- data/test/regression/test_hyperlink47.rb +27 -0
- data/test/regression/test_hyperlink48.rb +31 -0
- data/test/regression/test_hyperlink49.rb +29 -0
- data/test/regression/test_image06.rb +5 -5
- data/test/regression/test_image08.rb +5 -4
- data/test/regression/test_image15.rb +4 -2
- data/test/regression/test_image28.rb +1 -1
- data/test/regression/test_image36.rb +26 -0
- data/test/regression/test_image44.rb +28 -0
- data/test/regression/test_image45.rb +29 -0
- data/test/regression/test_image46.rb +29 -0
- data/test/regression/test_image47.rb +28 -0
- data/test/regression/test_image48.rb +32 -0
- data/test/regression/test_image49.rb +38 -0
- data/test/regression/test_image50.rb +24 -0
- data/test/regression/test_image51.rb +30 -0
- data/test/regression/test_object_position01.rb +26 -0
- data/test/regression/test_object_position02.rb +26 -0
- data/test/regression/test_object_position03.rb +26 -0
- data/test/regression/test_object_position04.rb +44 -0
- data/test/regression/test_object_position06.rb +28 -0
- data/test/regression/test_object_position07.rb +28 -0
- data/test/regression/test_object_position08.rb +47 -0
- data/test/regression/test_object_position09.rb +50 -0
- data/test/regression/test_object_position10.rb +28 -0
- data/test/regression/test_object_position12.rb +25 -0
- data/test/regression/test_object_position13.rb +25 -0
- data/test/regression/test_object_position14.rb +25 -0
- data/test/regression/test_object_position15.rb +29 -0
- data/test/regression/test_object_position16.rb +29 -0
- data/test/regression/test_object_position17.rb +29 -0
- data/test/regression/test_object_position18.rb +29 -0
- data/test/regression/test_object_position19.rb +29 -0
- data/test/regression/test_object_position20.rb +29 -0
- data/test/regression/test_shape_connect01.rb +4 -2
- data/test/regression/test_table23.rb +56 -0
- data/test/regression/test_table24.rb +27 -0
- data/test/regression/test_table25.rb +27 -0
- data/test/regression/xlsx_files/array_formula03.xlsx +0 -0
- data/test/regression/xlsx_files/autofilter08.xlsx +0 -0
- data/test/regression/xlsx_files/autofilter09.xlsx +0 -0
- data/test/regression/xlsx_files/autofilter10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis33.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis42.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis43.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis44.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis45.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis46.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined11.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_font09.xlsx +0 -0
- data/test/regression/xlsx_files/chart_legend03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_legend04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_legend05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_legend06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_legend07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
- data/test/regression/xlsx_files/comment13.xlsx +0 -0
- data/test/regression/xlsx_files/comment14.xlsx +0 -0
- data/test/regression/xlsx_files/comment15.xlsx +0 -0
- data/test/regression/xlsx_files/comment16.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format19.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format20.xlsx +0 -0
- data/test/regression/xlsx_files/format15.xlsx +0 -0
- data/test/regression/xlsx_files/header_image15.xlsx +0 -0
- data/test/regression/xlsx_files/header_image16.xlsx +0 -0
- data/test/regression/xlsx_files/header_image17.xlsx +0 -0
- data/test/regression/xlsx_files/header_image18.xlsx +0 -0
- data/test/regression/xlsx_files/header_image19.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink32.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink33.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink34.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink35.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink36.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink37.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink38.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink39.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink40.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink41.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink42.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink43.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink44.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink45.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink47.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink48.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink49.xlsx +0 -0
- data/test/regression/xlsx_files/image06.xlsx +0 -0
- data/test/regression/xlsx_files/image36.xlsx +0 -0
- data/test/regression/xlsx_files/image44.xlsx +0 -0
- data/test/regression/xlsx_files/image45.xlsx +0 -0
- data/test/regression/xlsx_files/image46.xlsx +0 -0
- data/test/regression/xlsx_files/image47.xlsx +0 -0
- data/test/regression/xlsx_files/image48.xlsx +0 -0
- data/test/regression/xlsx_files/image49.xlsx +0 -0
- data/test/regression/xlsx_files/image50.xlsx +0 -0
- data/test/regression/xlsx_files/image51.xlsx +0 -0
- data/test/regression/xlsx_files/object_position01.xlsx +0 -0
- data/test/regression/xlsx_files/object_position02.xlsx +0 -0
- data/test/regression/xlsx_files/object_position03.xlsx +0 -0
- data/test/regression/xlsx_files/object_position04.xlsx +0 -0
- data/test/regression/xlsx_files/object_position06.xlsx +0 -0
- data/test/regression/xlsx_files/object_position07.xlsx +0 -0
- data/test/regression/xlsx_files/object_position08.xlsx +0 -0
- data/test/regression/xlsx_files/object_position09.xlsx +0 -0
- data/test/regression/xlsx_files/object_position10.xlsx +0 -0
- data/test/regression/xlsx_files/object_position12.xlsx +0 -0
- data/test/regression/xlsx_files/object_position13.xlsx +0 -0
- data/test/regression/xlsx_files/object_position14.xlsx +0 -0
- data/test/regression/xlsx_files/object_position15.xlsx +0 -0
- data/test/regression/xlsx_files/object_position16.xlsx +0 -0
- data/test/regression/xlsx_files/object_position17.xlsx +0 -0
- data/test/regression/xlsx_files/object_position18.xlsx +0 -0
- data/test/regression/xlsx_files/object_position19.xlsx +0 -0
- data/test/regression/xlsx_files/object_position20.xlsx +0 -0
- data/test/regression/xlsx_files/table23.xlsx +0 -0
- data/test/regression/xlsx_files/table24.xlsx +0 -0
- data/test/regression/xlsx_files/table25.xlsx +0 -0
- data/test/test_example_match.rb +955 -780
- data/test/workbook/test_check_sheetname.rb +51 -0
- data/test/workbook/test_write_workbook_view.rb +36 -0
- data/test/worksheet/test_write_data_validation_02.rb +17 -0
- data/test/worksheet/test_write_sheet_view.rb +19 -1
- data/write_xlsx.gemspec +1 -0
- metadata +349 -7
- data/test/package/comments/test_write_text_t.rb +0 -44
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -16,7 +16,7 @@ class Axis < Caption
|
|
16
16
|
attr_reader :log_base, :crossing, :position_axis, :label_position, :visible
|
17
17
|
attr_reader :num_format_linked, :num_font, :layout, :interval_unit
|
18
18
|
attr_reader :interval_tick, :major_gridlines, :minor_gridlines, :reverse
|
19
|
-
attr_reader :line, :fill, :text_axis
|
19
|
+
attr_reader :line, :fill, :text_axis, :label_align
|
20
20
|
#
|
21
21
|
# Convert user defined axis values into axis instance.
|
22
22
|
#
|
@@ -28,7 +28,7 @@ def merge_with_hash(params) # :nodoc:
|
|
28
28
|
:reverse, :min, :max, :minor_unit, :major_unit, :minor_unit_type,
|
29
29
|
:major_unit_type, :log_base, :crossing, :position_axis,
|
30
30
|
:label_position, :num_format, :num_format_linked, :interval_unit,
|
31
|
-
:interval_tick, :line, :fill
|
31
|
+
:interval_tick, :line, :fill, :label_align
|
32
32
|
].each { |val| instance_variable_set("@#{val}", args[val]) }
|
33
33
|
set_major_minor_gridlines(args)
|
34
34
|
|
data/lib/write_xlsx/chart/bar.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Excel::Writer::XLSX::Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2014, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -22,9 +22,17 @@ class Line < self
|
|
22
22
|
|
23
23
|
def initialize(subtype)
|
24
24
|
super(subtype)
|
25
|
+
@subtype = @subtype || 'standard'
|
25
26
|
@default_marker = Marker.new(:type => 'none')
|
26
27
|
@smooth_allowed = 1
|
27
28
|
|
29
|
+
# Override and reset the default axis values.
|
30
|
+
if @subtype == 'percent_stacked'
|
31
|
+
@y_axis.defaults[:num_format] = '0%'
|
32
|
+
end
|
33
|
+
|
34
|
+
set_y_axis
|
35
|
+
|
28
36
|
# Set the available data label positions for this chart type.
|
29
37
|
@label_position_default = 'right'
|
30
38
|
@label_positions = {
|
@@ -54,9 +62,15 @@ def write_line_chart(params)
|
|
54
62
|
series = axes_series(params)
|
55
63
|
return if series.empty?
|
56
64
|
|
65
|
+
if @subtype == 'percent_stacked'
|
66
|
+
subtype = 'percentStacked'
|
67
|
+
else
|
68
|
+
subtype = @subtype
|
69
|
+
end
|
70
|
+
|
57
71
|
@writer.tag_elements('c:lineChart') do
|
58
72
|
# Write the c:grouping element.
|
59
|
-
write_grouping(
|
73
|
+
write_grouping(subtype)
|
60
74
|
# Write the series elements.
|
61
75
|
series.each {|s| write_series(s)}
|
62
76
|
|
data/lib/write_xlsx/chart/pie.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -42,13 +42,6 @@ def initialize(subtype)
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
#
|
46
|
-
# Override parent method to add a warning.
|
47
|
-
#
|
48
|
-
def combine(chart)
|
49
|
-
raise "Combined chart not currently supported for Pie charts"
|
50
|
-
end
|
51
|
-
|
52
45
|
#
|
53
46
|
# Set the Pie/Doughnut chart rotation: the angle of the first slice.
|
54
47
|
#
|
@@ -91,11 +84,31 @@ def write_pie_chart
|
|
91
84
|
# Write the <c:plotArea> element.
|
92
85
|
#
|
93
86
|
def write_plot_area
|
87
|
+
second_chart = @combined
|
88
|
+
|
94
89
|
@writer.tag_elements('c:plotArea') do
|
95
90
|
# Write the c:layout element.
|
96
91
|
write_layout(@plotarea.layout, 'plot')
|
97
92
|
# Write the subclass chart type element.
|
98
93
|
write_chart_type
|
94
|
+
# Configure a combined chart if present.
|
95
|
+
if second_chart
|
96
|
+
# Secondary axis has unique id otherwise use same as primary.
|
97
|
+
if second_chart.is_secondary?
|
98
|
+
second_chart.id = 1000 + @id
|
99
|
+
else
|
100
|
+
second_chart.id = @id
|
101
|
+
end
|
102
|
+
|
103
|
+
# Share the same filehandle for writing
|
104
|
+
second_chart.writer = @writer
|
105
|
+
|
106
|
+
# Share series index with primary chart.
|
107
|
+
second_chart.series_index = @series_index
|
108
|
+
|
109
|
+
# Write the subclass chart type elements for combined chart.
|
110
|
+
second_chart.write_chart_type
|
111
|
+
end
|
99
112
|
# Write the c:spPr eleent for the plotarea formatting.
|
100
113
|
write_sp_pr(@plotarea)
|
101
114
|
end
|
@@ -107,15 +120,15 @@ def write_plot_area
|
|
107
120
|
# Write the <c:legend> element.
|
108
121
|
#
|
109
122
|
def write_legend
|
110
|
-
position = @
|
123
|
+
position = @legend.position
|
111
124
|
allowed = %w(right left top bottom)
|
112
|
-
delete_series = @
|
125
|
+
delete_series = @legend.delete_series || []
|
113
126
|
|
114
|
-
if @
|
115
|
-
position = @
|
127
|
+
if @legend.position =~ /^overlay_/
|
128
|
+
position = @legend.position.sub(/^overlay_/, '')
|
116
129
|
overlay = true
|
117
130
|
else
|
118
|
-
position = @
|
131
|
+
position = @legend.position
|
119
132
|
overlay = false
|
120
133
|
end
|
121
134
|
|
@@ -129,11 +142,13 @@ def write_legend
|
|
129
142
|
# Write the c:legendEntry element.
|
130
143
|
delete_series.each { |index| write_legend_entry(index) }
|
131
144
|
# Write the c:layout element.
|
132
|
-
write_layout(@
|
145
|
+
write_layout(@legend.layout, 'legend')
|
133
146
|
# Write the c:overlay element.
|
134
147
|
write_overlay if overlay
|
148
|
+
# Write the c:spPr element.
|
149
|
+
write_sp_pr(@legend)
|
135
150
|
# Write the c:txPr element. Over-ridden.
|
136
|
-
write_tx_pr_legend(0, @
|
151
|
+
write_tx_pr_legend(0, @legend.font)
|
137
152
|
end
|
138
153
|
end
|
139
154
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2012, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# See formatting note in Chart.
|
9
9
|
#
|
10
10
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
11
|
-
# Convert to ruby by Hideo NAKAMURA,
|
11
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
12
12
|
#
|
13
13
|
|
14
14
|
require 'write_xlsx/package/xml_writer_simple'
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Used in conjunction with WriteXLSX
|
7
7
|
#
|
8
8
|
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
|
9
|
-
# Convert to ruby by Hideo NAKAMURA,
|
9
|
+
# Convert to ruby by Hideo NAKAMURA, nakamura.hideo@gmail.com
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'write_xlsx/worksheet'
|
@@ -19,7 +19,7 @@ class Chartsheet < Worksheet
|
|
19
19
|
|
20
20
|
def initialize(workbook, index, name)
|
21
21
|
super
|
22
|
-
@
|
22
|
+
@drawings = Drawings.new
|
23
23
|
@is_chartsheet = true
|
24
24
|
@chart = nil
|
25
25
|
@charts = [1]
|
@@ -57,11 +57,39 @@ def assemble_xml_file # :nodoc:
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def protect(password = '', options = {})
|
60
|
+
def protect(password = '', user_options = nil, options = {})
|
61
|
+
# Objects are default on for chartsheets.
|
62
|
+
if user_options
|
63
|
+
if user_options.has_key?(:objects)
|
64
|
+
if ptrue?(user_options[:objects])
|
65
|
+
options[:objects] = 0
|
66
|
+
else
|
67
|
+
options[:objects] = 1
|
68
|
+
end
|
69
|
+
else
|
70
|
+
options[:objects] = 0
|
71
|
+
end
|
72
|
+
|
73
|
+
if user_options.has_key?(:content)
|
74
|
+
options[:content] = user_options[:content]
|
75
|
+
else
|
76
|
+
options[:content] = 1
|
77
|
+
end
|
78
|
+
else
|
79
|
+
options[:objects] = 0
|
80
|
+
options[:content] = 1
|
81
|
+
end
|
82
|
+
|
83
|
+
# Is objects and content are off then the chartsheet isn't locked.
|
84
|
+
# except if it has a password.
|
85
|
+
if password == '' && ptrue?(options[:objects]) && !ptrue?(options[:content])
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
61
89
|
@chart.protection = 1
|
62
90
|
|
91
|
+
# Turn off worksheet defaults.
|
63
92
|
options[:sheet] = 0
|
64
|
-
options[:content] = 1
|
65
93
|
options[:scenarios] = 1
|
66
94
|
|
67
95
|
super(password, options)
|
@@ -148,9 +176,9 @@ def set_high_low_lines(*args)
|
|
148
176
|
def prepare_chart(index, chart_id, drawing_id) # :nodoc:
|
149
177
|
@chart.id = chart_id - 1
|
150
178
|
|
151
|
-
|
152
|
-
@
|
153
|
-
@
|
179
|
+
drawings = Drawings.new
|
180
|
+
@drawings = drawings
|
181
|
+
@drawings.orientation = @page_setup.orientation
|
154
182
|
|
155
183
|
@external_drawing_links << [ '/drawing', "../drawings/drawing#{drawing_id}.xml" ]
|
156
184
|
|
data/lib/write_xlsx/drawing.rb
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
|
5
5
|
module Writexlsx
|
6
6
|
class Drawing
|
7
|
+
attr_accessor :type, :dimensions, :width, :height, :description, :shape, :anchor, :rel_index, :url_rel_index
|
8
|
+
attr_reader :tip
|
9
|
+
|
10
|
+
def initialize(type, dimensions, width, height, description, shape, anchor, rel_index = nil, url_rel_index = nil, tip = nil)
|
11
|
+
@type, @dimensions, @width, @height, @description, @shape, @anchor, @rel_index, @url_rel_index, @tip =
|
12
|
+
type, dimensions, width, height, description, shape, anchor, rel_index, url_rel_index, tip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Drawings
|
7
17
|
include Writexlsx::Utility
|
8
18
|
|
9
19
|
attr_writer :embedded, :orientation
|
@@ -32,10 +42,10 @@ def assemble_xml_file
|
|
32
42
|
write_drawing_workspace do
|
33
43
|
if @embedded
|
34
44
|
index = 0
|
35
|
-
@drawings.each do |
|
45
|
+
@drawings.each do |drawing|
|
36
46
|
# Write the xdr:twoCellAnchor element.
|
37
47
|
index += 1
|
38
|
-
write_two_cell_anchor(index,
|
48
|
+
write_two_cell_anchor(index, drawing)
|
39
49
|
end
|
40
50
|
else
|
41
51
|
# Write the xdr:absoluteAnchor element.
|
@@ -48,8 +58,8 @@ def assemble_xml_file
|
|
48
58
|
#
|
49
59
|
# Add a chart, image or shape sub object to the drawing.
|
50
60
|
#
|
51
|
-
def add_drawing_object(
|
52
|
-
@drawings <<
|
61
|
+
def add_drawing_object(drawing)
|
62
|
+
@drawings << drawing
|
53
63
|
end
|
54
64
|
|
55
65
|
private
|
@@ -71,14 +81,29 @@ def write_drawing_workspace
|
|
71
81
|
# Write the <xdr:twoCellAnchor> element.
|
72
82
|
#
|
73
83
|
def write_two_cell_anchor(*args)
|
74
|
-
index,
|
75
|
-
|
76
|
-
|
84
|
+
index, drawing = args
|
85
|
+
|
86
|
+
type = drawing.type
|
87
|
+
width = drawing.width
|
88
|
+
height = drawing.height
|
89
|
+
description = drawing.description
|
90
|
+
shape = drawing.shape
|
91
|
+
anchor = drawing.anchor
|
92
|
+
rel_index = drawing.rel_index
|
93
|
+
url_rel_index = drawing.url_rel_index
|
94
|
+
tip = drawing.tip
|
95
|
+
|
96
|
+
col_from, row_from, col_from_offset, row_from_offset,
|
97
|
+
col_to, row_to, col_to_offset, row_to_offset, col_absolute, row_absolute = drawing.dimensions
|
77
98
|
|
78
99
|
attributes = []
|
79
100
|
|
80
101
|
# Add attribute for images.
|
81
|
-
|
102
|
+
if anchor == 2
|
103
|
+
attributes << [:editAs, 'oneCell']
|
104
|
+
elsif anchor == 3
|
105
|
+
attributes << [:editAs, 'absolute']
|
106
|
+
end
|
82
107
|
|
83
108
|
# Add attribute for shapes.
|
84
109
|
attributes << [:editAs, shape.edit_as] if shape && shape.edit_as
|
@@ -93,10 +118,14 @@ def write_two_cell_anchor(*args)
|
|
93
118
|
# Graphic frame.
|
94
119
|
|
95
120
|
# Write the xdr:graphicFrame element for charts.
|
96
|
-
write_graphic_frame(index, description)
|
121
|
+
write_graphic_frame(index, rel_index, description)
|
97
122
|
elsif type == 2
|
98
123
|
# Write the xdr:pic element.
|
99
|
-
write_pic(
|
124
|
+
write_pic(
|
125
|
+
index, rel_index, col_absolute,
|
126
|
+
row_absolute, width, height,
|
127
|
+
description, url_rel_index , tip
|
128
|
+
)
|
100
129
|
else
|
101
130
|
# Write the xdr:sp element for shapes.
|
102
131
|
write_sp(index, col_absolute, row_absolute, width, height, shape)
|
@@ -129,7 +158,7 @@ def write_absolute_anchor(index)
|
|
129
158
|
end
|
130
159
|
|
131
160
|
# Write the xdr:graphicFrame element.
|
132
|
-
write_graphic_frame(index)
|
161
|
+
write_graphic_frame(index, index)
|
133
162
|
|
134
163
|
# Write the xdr:clientData element.
|
135
164
|
write_client_data
|
@@ -203,9 +232,9 @@ def write_row_off(data)
|
|
203
232
|
#
|
204
233
|
def write_pos(x, y)
|
205
234
|
attributes = [
|
206
|
-
|
207
|
-
|
208
|
-
|
235
|
+
['x', x],
|
236
|
+
['y', y]
|
237
|
+
]
|
209
238
|
|
210
239
|
@writer.empty_tag('xdr:pos', attributes)
|
211
240
|
end
|
@@ -215,9 +244,9 @@ def write_pos(x, y)
|
|
215
244
|
#
|
216
245
|
def write_ext(cx, cy)
|
217
246
|
attributes = [
|
218
|
-
|
219
|
-
|
220
|
-
|
247
|
+
['cx', cx],
|
248
|
+
['cy', cy]
|
249
|
+
]
|
221
250
|
|
222
251
|
@writer.empty_tag('xdr:ext', attributes)
|
223
252
|
end
|
@@ -225,7 +254,7 @@ def write_ext(cx, cy)
|
|
225
254
|
#
|
226
255
|
# Write the <xdr:graphicFrame> element.
|
227
256
|
#
|
228
|
-
def write_graphic_frame(index, name = nil)
|
257
|
+
def write_graphic_frame(index, rel_index, name = nil)
|
229
258
|
macro = ''
|
230
259
|
|
231
260
|
attributes = [ ['macro', macro] ]
|
@@ -236,7 +265,7 @@ def write_graphic_frame(index, name = nil)
|
|
236
265
|
# Write the xdr:xfrm element.
|
237
266
|
write_xfrm
|
238
267
|
# Write the a:graphic element.
|
239
|
-
write_atag_graphic(
|
268
|
+
write_atag_graphic(rel_index)
|
240
269
|
end
|
241
270
|
end
|
242
271
|
|
@@ -257,18 +286,42 @@ def write_nv_graphic_frame_pr(index, name = nil)
|
|
257
286
|
#
|
258
287
|
# Write the <xdr:cNvPr> element.
|
259
288
|
#
|
260
|
-
def write_c_nv_pr(
|
289
|
+
def write_c_nv_pr(index, name, description = nil, url_rel_index = nil, tip = nil)
|
261
290
|
attributes = [
|
262
|
-
|
263
|
-
|
291
|
+
['id', index],
|
292
|
+
['name', name]
|
264
293
|
]
|
265
294
|
|
266
295
|
# Add description attribute for images.
|
267
|
-
attributes << ['descr',
|
296
|
+
attributes << ['descr', description] if description
|
268
297
|
|
269
|
-
|
298
|
+
if ptrue?(url_rel_index)
|
299
|
+
@writer.tag_elements('xdr:cNvPr', attributes) do
|
300
|
+
# Write the a:hlinkClick element.
|
301
|
+
write_a_hlink_click(url_rel_index, tip)
|
302
|
+
end
|
303
|
+
else
|
304
|
+
@writer.empty_tag('xdr:cNvPr', attributes)
|
305
|
+
end
|
270
306
|
end
|
271
307
|
|
308
|
+
#
|
309
|
+
# Write the <a:hlinkClick> element.
|
310
|
+
#
|
311
|
+
def write_a_hlink_click(index, tip)
|
312
|
+
schema = 'http://schemas.openxmlformats.org/officeDocument/'
|
313
|
+
xmlns_r = "#{schema}2006/relationships"
|
314
|
+
r_id = "rId#{index}"
|
315
|
+
|
316
|
+
attributes = [
|
317
|
+
['xmlns:r', xmlns_r],
|
318
|
+
['r:id', r_id]
|
319
|
+
]
|
320
|
+
|
321
|
+
attributes << ['tooltip', tip] if tip
|
322
|
+
|
323
|
+
@writer.empty_tag('a:hlinkClick', attributes)
|
324
|
+
end
|
272
325
|
|
273
326
|
#
|
274
327
|
# Write the <xdr:cNvGraphicFramePr> element.
|
@@ -351,7 +404,7 @@ def write_atag_graphic(index)
|
|
351
404
|
# Write the <a:graphicData> element.
|
352
405
|
#
|
353
406
|
def write_atag_graphic_data(index)
|
354
|
-
uri
|
407
|
+
uri = 'http://schemas.openxmlformats.org/drawingml/2006/chart'
|
355
408
|
|
356
409
|
attributes = [ ['uri', uri] ]
|
357
410
|
|
@@ -474,12 +527,12 @@ def write_nv_sp_pr(index, shape)
|
|
474
527
|
#
|
475
528
|
# Write the <xdr:pic> element.
|
476
529
|
#
|
477
|
-
def write_pic(index, col_absolute, row_absolute, width, height, description)
|
530
|
+
def write_pic(index, rel_index, col_absolute, row_absolute, width, height, description, url_rel_index, tip)
|
478
531
|
@writer.tag_elements('xdr:pic') do
|
479
532
|
# Write the xdr:nvPicPr element.
|
480
|
-
write_nv_pic_pr(index, description)
|
533
|
+
write_nv_pic_pr(index, rel_index, description, url_rel_index, tip)
|
481
534
|
# Write the xdr:blipFill element.
|
482
|
-
write_blip_fill(
|
535
|
+
write_blip_fill(rel_index)
|
483
536
|
|
484
537
|
# Pictures are rectangle shapes by default.
|
485
538
|
shape = Shape.new
|
@@ -493,10 +546,13 @@ def write_pic(index, col_absolute, row_absolute, width, height, description)
|
|
493
546
|
#
|
494
547
|
# Write the <xdr:nvPicPr> element.
|
495
548
|
#
|
496
|
-
def write_nv_pic_pr(index, description)
|
549
|
+
def write_nv_pic_pr(index, rel_index, description, url_rel_index, tip)
|
497
550
|
@writer.tag_elements('xdr:nvPicPr') do
|
498
551
|
# Write the xdr:cNvPr element.
|
499
|
-
write_c_nv_pr(
|
552
|
+
write_c_nv_pr(
|
553
|
+
index + 1, "Picture #{index}", description,
|
554
|
+
url_rel_index, tip
|
555
|
+
)
|
500
556
|
# Write the xdr:cNvPicPr element.
|
501
557
|
write_c_nv_pic_pr
|
502
558
|
end
|