write_xlsx 0.89.0 → 1.01.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 +98 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/examples/a_simple.rb +2 -7
- 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 +5 -2
- 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/conditional_format.rb +73 -46
- data/examples/data_validate.rb +1 -1
- data/examples/date_time.rb +1 -1
- data/examples/demo.rb +5 -8
- 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 +5 -12
- 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 +1 -1
- data/lib/write_xlsx/chart.rb +124 -240
- data/lib/write_xlsx/chart/area.rb +1 -1
- data/lib/write_xlsx/chart/axis.rb +4 -4
- data/lib/write_xlsx/chart/bar.rb +1 -1
- data/lib/write_xlsx/chart/caption.rb +3 -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 +1 -1
- data/lib/write_xlsx/chart/pie.rb +32 -15
- data/lib/write_xlsx/chart/radar.rb +1 -1
- data/lib/write_xlsx/chart/scatter.rb +1 -1
- data/lib/write_xlsx/chart/series.rb +11 -7
- data/lib/write_xlsx/chart/stock.rb +1 -1
- data/lib/write_xlsx/chartsheet.rb +35 -7
- data/lib/write_xlsx/drawing.rb +28 -8
- data/lib/write_xlsx/format.rb +19 -15
- data/lib/write_xlsx/package/comments.rb +57 -54
- data/lib/write_xlsx/package/conditional_format.rb +360 -39
- data/lib/write_xlsx/package/content_types.rb +10 -0
- data/lib/write_xlsx/package/core.rb +8 -6
- data/lib/write_xlsx/package/custom.rb +125 -0
- data/lib/write_xlsx/package/packager.rb +26 -0
- data/lib/write_xlsx/package/styles.rb +53 -21
- data/lib/write_xlsx/package/table.rb +16 -4
- data/lib/write_xlsx/shape.rb +4 -3
- data/lib/write_xlsx/sheets.rb +11 -1
- data/lib/write_xlsx/sparkline.rb +1 -1
- data/lib/write_xlsx/utility.rb +305 -35
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +132 -12
- data/lib/write_xlsx/worksheet.rb +397 -163
- data/lib/write_xlsx/worksheet/data_validation.rb +10 -14
- data/lib/write_xlsx/worksheet/hyperlink.rb +4 -13
- 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/helper.rb +6 -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/formats.xlsx +0 -0
- data/test/regression/_test_hyperlink31.rb +26 -0
- data/test/regression/images/happy.jpg +0 -0
- data/test/regression/images/zero_dpi.jpg +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_bar08.rb +3 -0
- data/test/regression/test_chart_bar11.rb +3 -0
- data/test/regression/test_chart_bar14.rb +3 -0
- data/test/regression/test_chart_chartarea05.rb +16 -17
- data/test/regression/test_chart_chartarea06.rb +49 -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 +61 -0
- data/test/regression/test_chart_doughnut07.rb +37 -0
- data/test/regression/test_chart_font09.rb +1 -1
- data/test/regression/test_chart_format26.rb +48 -0
- data/test/regression/test_chart_format27.rb +58 -0
- data/test/regression/test_chart_format28.rb +52 -0
- data/test/regression/test_chart_format29.rb +59 -0
- data/test/regression/test_chart_format30.rb +53 -0
- data/test/regression/test_chart_format31.rb +60 -0
- 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_size03.rb +4 -1
- data/test/regression/test_chart_table03.rb +56 -0
- data/test/regression/test_comment13.rb +36 -0
- data/test/regression/test_comment14.rb +29 -0
- data/test/regression/test_cond_format14.rb +42 -0
- data/test/regression/test_cond_format15.rb +53 -0
- data/test/regression/test_cond_format16.rb +53 -0
- data/test/regression/test_cond_format17.rb +37 -0
- data/test/regression/test_cond_format18.rb +136 -0
- data/test/regression/test_cond_format19.rb +64 -0
- data/test/regression/test_cond_format20.rb +43 -0
- data/test/regression/test_date_1904_01.rb +1 -1
- data/test/regression/test_escapes04.rb +3 -0
- data/test/regression/test_escapes05.rb +3 -0
- data/test/regression/test_escapes07.rb +3 -0
- data/test/regression/test_escapes08.rb +3 -0
- data/test/regression/test_format15.rb +26 -0
- data/test/regression/test_hyperlink01.rb +3 -0
- data/test/regression/test_hyperlink02.rb +3 -0
- data/test/regression/test_hyperlink03.rb +4 -0
- data/test/regression/test_hyperlink04.rb +3 -0
- data/test/regression/test_hyperlink05.rb +3 -0
- data/test/regression/test_hyperlink06.rb +3 -0
- data/test/regression/test_hyperlink07.rb +3 -0
- data/test/regression/test_hyperlink08.rb +3 -0
- data/test/regression/test_hyperlink09.rb +3 -0
- data/test/regression/test_hyperlink10.rb +3 -0
- data/test/regression/test_hyperlink11.rb +3 -0
- data/test/regression/test_hyperlink12.rb +3 -0
- data/test/regression/test_hyperlink13.rb +3 -0
- data/test/regression/test_hyperlink14.rb +3 -0
- data/test/regression/test_hyperlink15.rb +3 -0
- data/test/regression/test_hyperlink16.rb +3 -0
- data/test/regression/test_hyperlink17.rb +3 -0
- data/test/regression/test_hyperlink18.rb +3 -0
- data/test/regression/test_hyperlink20.rb +3 -0
- data/test/regression/test_hyperlink21.rb +3 -0
- data/test/regression/test_hyperlink22.rb +3 -0
- data/test/regression/test_hyperlink23.rb +3 -0
- data/test/regression/test_hyperlink24.rb +3 -0
- data/test/regression/test_hyperlink25.rb +3 -0
- data/test/regression/test_hyperlink26.rb +3 -0
- data/test/regression/test_hyperlink27.rb +27 -0
- data/test/regression/test_hyperlink28.rb +50 -0
- data/test/regression/test_hyperlink29.rb +27 -0
- data/test/regression/test_hyperlink30.rb +36 -0
- 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_image35.rb +26 -0
- data/test/regression/test_image36.rb +26 -0
- data/test/regression/test_image44.rb +28 -0
- data/test/regression/test_image45.rb +28 -0
- data/test/regression/test_image46.rb +29 -0
- data/test/regression/test_image47.rb +28 -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_properties01.rb +1 -4
- data/test/regression/test_properties02.rb +1 -4
- data/test/regression/test_properties03.rb +26 -0
- data/test/regression/test_properties04.rb +61 -0
- data/test/regression/test_properties05.rb +30 -0
- data/test/regression/test_shape_connect01.rb +4 -2
- data/test/regression/test_table03.rb +3 -0
- data/test/regression/test_table04.rb +3 -0
- data/test/regression/test_table05.rb +3 -0
- data/test/regression/test_table06.rb +3 -0
- data/test/regression/test_table20.rb +34 -0
- data/test/regression/test_table21.rb +36 -0
- data/test/regression/test_table22.rb +32 -0
- data/test/regression/test_table23.rb +56 -0
- data/test/regression/test_utf8_11.rb +23 -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_chartarea05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_chartarea06.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_format26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format31.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_table03.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/cond_format14.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format18.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/date_1904_01.xlsx +0 -0
- data/test/regression/xlsx_files/format15.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink27.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
- data/test/regression/xlsx_files/image35.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/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/properties03.xlsx +0 -0
- data/test/regression/xlsx_files/properties04.xlsx +0 -0
- data/test/regression/xlsx_files/properties05.xlsx +0 -0
- data/test/regression/xlsx_files/table21.xlsx +0 -0
- data/test/regression/xlsx_files/table22.xlsx +0 -0
- data/test/regression/xlsx_files/table23.xlsx +0 -0
- data/test/regression/xlsx_files/utf8_11.xlsx +0 -0
- data/test/test_example_match.rb +836 -771
- data/test/workbook/test_check_sheetname.rb +61 -0
- data/test/workbook/test_worksheet_by_name.rb +35 -0
- data/test/workbook/test_write_workbook_view.rb +117 -0
- data/test/worksheet/test_cond_format_22.rb +266 -0
- data/test/worksheet/test_cond_format_23.rb +242 -0
- data/test/worksheet/test_cond_format_24.rb +303 -0
- data/test/worksheet/test_data_bar_01.rb +53 -0
- data/test/worksheet/test_data_bar_02.rb +79 -0
- data/test/worksheet/test_data_bar_03.rb +147 -0
- data/test/worksheet/test_data_bar_04.rb +145 -0
- data/test/worksheet/test_data_bar_05.rb +147 -0
- data/test/worksheet/test_data_bar_06.rb +145 -0
- data/test/worksheet/test_data_bar_07.rb +146 -0
- data/test/worksheet/test_data_bar_08.rb +54 -0
- data/test/worksheet/test_data_bar_09.rb +80 -0
- data/test/worksheet/test_data_bar_10.rb +165 -0
- data/test/worksheet/test_data_bar_11.rb +167 -0
- data/test/worksheet/test_data_bar_12.rb +104 -0
- data/test/worksheet/test_write_data_validation_02.rb +44 -0
- data/test/worksheet/test_write_hyperlink.rb +0 -7
- data/test/worksheet/test_write_sheet_view.rb +19 -1
- metadata +308 -5
- 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
|
|
@@ -184,8 +184,8 @@ def set_position_axis
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def set_font_properties(args)
|
187
|
-
@num_font =
|
188
|
-
@name_font =
|
187
|
+
@num_font = convert_font_args(args[:num_font])
|
188
|
+
@name_font = convert_font_args(args[:name_font])
|
189
189
|
end
|
190
190
|
|
191
191
|
def set_axis_name_layout(args)
|
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'
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Writexlsx
|
4
4
|
class Chart
|
5
5
|
class Caption
|
6
|
+
include Writexlsx::Utility
|
7
|
+
|
6
8
|
attr_accessor :name, :formula, :data_id, :name_font
|
7
9
|
attr_reader :layout, :overlay, :none
|
8
10
|
|
@@ -13,7 +15,7 @@ def initialize(chart)
|
|
13
15
|
def merge_with_hash(params) # :nodoc:
|
14
16
|
@name, @formula = @chart.process_names(params[:name], params[:name_formula])
|
15
17
|
@data_id = @chart.data_id(@formula, params[:data])
|
16
|
-
@name_font =
|
18
|
+
@name_font = convert_font_args(params[:name_font])
|
17
19
|
@layout = @chart.layout_properties(params[:layout], 1)
|
18
20
|
|
19
21
|
# Set the title overlay option.
|
@@ -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'
|
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,33 @@ 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
|
112
|
+
# Write the c:spPr eleent for the plotarea formatting.
|
113
|
+
write_sp_pr(@plotarea)
|
99
114
|
end
|
100
115
|
end
|
101
116
|
|
@@ -105,15 +120,15 @@ def write_plot_area
|
|
105
120
|
# Write the <c:legend> element.
|
106
121
|
#
|
107
122
|
def write_legend
|
108
|
-
position = @
|
123
|
+
position = @legend.position
|
109
124
|
allowed = %w(right left top bottom)
|
110
|
-
delete_series = @
|
125
|
+
delete_series = @legend.delete_series || []
|
111
126
|
|
112
|
-
if @
|
113
|
-
position = @
|
127
|
+
if @legend.position =~ /^overlay_/
|
128
|
+
position = @legend.position.sub(/^overlay_/, '')
|
114
129
|
overlay = true
|
115
130
|
else
|
116
|
-
position = @
|
131
|
+
position = @legend.position
|
117
132
|
overlay = false
|
118
133
|
end
|
119
134
|
|
@@ -127,11 +142,13 @@ def write_legend
|
|
127
142
|
# Write the c:legendEntry element.
|
128
143
|
delete_series.each { |index| write_legend_entry(index) }
|
129
144
|
# Write the c:layout element.
|
130
|
-
write_layout(@
|
145
|
+
write_layout(@legend.layout, 'legend')
|
131
146
|
# Write the c:overlay element.
|
132
147
|
write_overlay if overlay
|
148
|
+
# Write the c:spPr element.
|
149
|
+
write_sp_pr(@legend)
|
133
150
|
# Write the c:txPr element. Over-ridden.
|
134
|
-
write_tx_pr_legend(0, @
|
151
|
+
write_tx_pr_legend(0, @legend.font)
|
135
152
|
end
|
136
153
|
end
|
137
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'
|
@@ -57,16 +57,20 @@ def initialize(params)
|
|
57
57
|
|
58
58
|
class Trendline < Chartline
|
59
59
|
attr_reader :name, :forward, :backward, :order, :period
|
60
|
+
attr_reader :intercept, :display_equation, :display_r_squared
|
60
61
|
|
61
62
|
def initialize(params)
|
62
63
|
super(params)
|
63
64
|
|
64
|
-
@name
|
65
|
-
@forward
|
66
|
-
@backward
|
67
|
-
@order
|
68
|
-
@period
|
69
|
-
@
|
65
|
+
@name = params[:name]
|
66
|
+
@forward = params[:forward]
|
67
|
+
@backward = params[:backward]
|
68
|
+
@order = params[:order]
|
69
|
+
@period = params[:period]
|
70
|
+
@intercept = params[:intercept]
|
71
|
+
@display_equation = params[:display_equation]
|
72
|
+
@display_r_squared = params[:display_r_squared]
|
73
|
+
@type = value_or_raise(types, params[:type], 'trendline type')
|
70
74
|
end
|
71
75
|
|
72
76
|
private
|
@@ -293,7 +297,7 @@ def labels_properties(labels) # :nodoc:
|
|
293
297
|
end
|
294
298
|
|
295
299
|
if labels[:font]
|
296
|
-
labels[:font] =
|
300
|
+
labels[:font] = convert_font_args(labels[:font])
|
297
301
|
end
|
298
302
|
|
299
303
|
labels
|
@@ -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,15 @@
|
|
4
4
|
|
5
5
|
module Writexlsx
|
6
6
|
class Drawing
|
7
|
+
attr_accessor :type, :dimensions, :width, :height, :name, :shape, :anchor
|
8
|
+
|
9
|
+
def initialize(type, dimensions, width, height, name, shape, anchor)
|
10
|
+
@type, @dimensions, @width, @height, @name, @shape, @anchor =
|
11
|
+
type, dimensions, width, height, name, shape, anchor
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Drawings
|
7
16
|
include Writexlsx::Utility
|
8
17
|
|
9
18
|
attr_writer :embedded, :orientation
|
@@ -32,10 +41,10 @@ def assemble_xml_file
|
|
32
41
|
write_drawing_workspace do
|
33
42
|
if @embedded
|
34
43
|
index = 0
|
35
|
-
@drawings.each do |
|
44
|
+
@drawings.each do |drawing|
|
36
45
|
# Write the xdr:twoCellAnchor element.
|
37
46
|
index += 1
|
38
|
-
write_two_cell_anchor(index,
|
47
|
+
write_two_cell_anchor(index, drawing)
|
39
48
|
end
|
40
49
|
else
|
41
50
|
# Write the xdr:absoluteAnchor element.
|
@@ -48,8 +57,8 @@ def assemble_xml_file
|
|
48
57
|
#
|
49
58
|
# Add a chart, image or shape sub object to the drawing.
|
50
59
|
#
|
51
|
-
def add_drawing_object(
|
52
|
-
@drawings <<
|
60
|
+
def add_drawing_object(drawing)
|
61
|
+
@drawings << drawing
|
53
62
|
end
|
54
63
|
|
55
64
|
private
|
@@ -71,14 +80,25 @@ def write_drawing_workspace
|
|
71
80
|
# Write the <xdr:twoCellAnchor> element.
|
72
81
|
#
|
73
82
|
def write_two_cell_anchor(*args)
|
74
|
-
index,
|
75
|
-
|
76
|
-
|
83
|
+
index, drawing = args
|
84
|
+
|
85
|
+
type = drawing.type
|
86
|
+
width = drawing.width
|
87
|
+
height = drawing.height
|
88
|
+
description = drawing.name
|
89
|
+
shape = drawing.shape
|
90
|
+
anchor = drawing.anchor
|
91
|
+
col_from, row_from, col_from_offset, row_from_offset,
|
92
|
+
col_to, row_to, col_to_offset, row_to_offset, col_absolute, row_absolute = drawing.dimensions
|
77
93
|
|
78
94
|
attributes = []
|
79
95
|
|
80
96
|
# Add attribute for images.
|
81
|
-
|
97
|
+
if anchor == 2
|
98
|
+
attributes << [:editAs, 'oneCell']
|
99
|
+
elsif anchor == 3
|
100
|
+
attributes << [:editAs, 'absolute']
|
101
|
+
end
|
82
102
|
|
83
103
|
# Add attribute for shapes.
|
84
104
|
attributes << [:editAs, shape.edit_as] if shape && shape.edit_as
|
data/lib/write_xlsx/format.rb
CHANGED
@@ -163,7 +163,7 @@ class Format
|
|
163
163
|
include Writexlsx::Utility
|
164
164
|
|
165
165
|
attr_reader :xf_index, :dxf_index, :num_format # :nodoc:
|
166
|
-
attr_reader :underline, :font_script, :size, :theme, :font, :font_family, :hyperlink # :nodoc:
|
166
|
+
attr_reader :underline, :font_script, :size, :theme, :font, :font_family, :hyperlink, :xf_id # :nodoc:
|
167
167
|
attr_reader :diag_type, :diag_color, :font_only, :color, :color_indexed # :nodoc:
|
168
168
|
attr_reader :left, :left_color, :right, :right_color, :top, :top_color, :bottom, :bottom_color # :nodoc:
|
169
169
|
attr_reader :font_scheme # :nodoc:
|
@@ -180,7 +180,7 @@ def initialize(formats, params = {}) # :nodoc:
|
|
180
180
|
@xf_index = nil
|
181
181
|
@dxf_index = nil
|
182
182
|
|
183
|
-
@num_format =
|
183
|
+
@num_format = 'General'
|
184
184
|
@num_format_index = 0
|
185
185
|
@font_index = 0
|
186
186
|
@font = 'Calibri'
|
@@ -200,6 +200,7 @@ def initialize(formats, params = {}) # :nodoc:
|
|
200
200
|
@font_extend = 0
|
201
201
|
@theme = 0
|
202
202
|
@hyperlink = 0
|
203
|
+
@xf_id = 0
|
203
204
|
|
204
205
|
@hidden = 0
|
205
206
|
@locked = 1
|
@@ -396,7 +397,8 @@ def get_font_key
|
|
396
397
|
@font,
|
397
398
|
@italic,
|
398
399
|
@size,
|
399
|
-
@underline
|
400
|
+
@underline,
|
401
|
+
@theme
|
400
402
|
].join(':')
|
401
403
|
end
|
402
404
|
|
@@ -476,13 +478,13 @@ def self.color(color_code)
|
|
476
478
|
|
477
479
|
colors = Colors::COLORS
|
478
480
|
|
481
|
+
# Return the default color if nil,
|
482
|
+
return 0x00 unless color_code
|
483
|
+
|
479
484
|
if color_code.respond_to?(:to_str)
|
480
485
|
# Return RGB style colors for processing later.
|
481
486
|
return color_code if color_code =~ /^#[0-9A-F]{6}$/i
|
482
487
|
|
483
|
-
# Return the default color if undef,
|
484
|
-
return 0x00 unless color_code
|
485
|
-
|
486
488
|
# or the color string converted to an integer,
|
487
489
|
return colors[color_code.downcase.to_sym] if colors[color_code.downcase.to_sym]
|
488
490
|
|
@@ -593,15 +595,15 @@ def set_rotation(rotation)
|
|
593
595
|
end
|
594
596
|
|
595
597
|
#
|
596
|
-
# Set the properties for the hyperlink style.
|
597
|
-
#
|
598
|
+
# Set the properties for the hyperlink style. This isn't a public method. To
|
599
|
+
# be fixed when styles are supported.
|
598
600
|
#
|
599
|
-
def set_hyperlink
|
600
|
-
@
|
601
|
+
def set_hyperlink(hyperlink)
|
602
|
+
@xf_id = 1
|
601
603
|
|
602
604
|
set_underline(1)
|
603
605
|
set_theme(10)
|
604
|
-
|
606
|
+
@hyperlink = hyperlink
|
605
607
|
end
|
606
608
|
|
607
609
|
def set_font_info(fonts)
|
@@ -804,11 +806,11 @@ def xf_attributes
|
|
804
806
|
['fontId' , font_index],
|
805
807
|
['fillId' , fill_index],
|
806
808
|
['borderId', border_index],
|
807
|
-
['xfId' ,
|
809
|
+
['xfId' , xf_id]
|
808
810
|
]
|
809
811
|
attributes << ['applyNumberFormat', 1] if num_format_index > 0
|
810
812
|
# Add applyFont attribute if XF format uses a font element.
|
811
|
-
attributes << ['applyFont', 1] if font_index > 0
|
813
|
+
attributes << ['applyFont', 1] if font_index > 0 && !ptrue?(@hyperlink)
|
812
814
|
# Add applyFill attribute if XF format uses a fill element.
|
813
815
|
attributes << ['applyFill', 1] if fill_index > 0
|
814
816
|
# Add applyBorder attribute if XF format uses a border element.
|
@@ -817,8 +819,10 @@ def xf_attributes
|
|
817
819
|
# Check if XF format has alignment properties set.
|
818
820
|
apply_align, align = get_align_properties
|
819
821
|
# We can also have applyAlignment without a sub-element.
|
820
|
-
attributes << ['applyAlignment', 1] if apply_align
|
821
|
-
|
822
|
+
attributes << ['applyAlignment', 1] if apply_align || ptrue?(@hyperlink)
|
823
|
+
if get_protection_properties || ptrue?(hyperlink)
|
824
|
+
attributes << ['applyProtection', 1]
|
825
|
+
end
|
822
826
|
|
823
827
|
attributes
|
824
828
|
end
|