write_xlsx 0.83.0 → 0.85.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +15 -0
- data/Changes +15 -0
- data/README.md +2 -2
- data/examples/chart_clustered.rb +63 -0
- data/examples/chart_styles.rb +53 -0
- data/lib/write_xlsx/chart.rb +191 -4
- data/lib/write_xlsx/chart/axis.rb +47 -4
- data/lib/write_xlsx/chart/series.rb +13 -2
- data/lib/write_xlsx/gradient.rb +74 -0
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +33 -15
- data/lib/write_xlsx/worksheet.rb +7 -1
- data/lib/write_xlsx/worksheet/cell_data.rb +11 -1
- data/lib/write_xlsx/worksheet/hyperlink.rb +25 -14
- data/lib/write_xlsx/worksheet/page_setup.rb +8 -7
- data/test/regression/test_chart_clustered01.rb +65 -0
- data/test/regression/test_chart_display_units01.rb +35 -0
- data/test/regression/test_chart_display_units02.rb +36 -0
- data/test/regression/test_chart_display_units03.rb +36 -0
- data/test/regression/test_chart_display_units04.rb +36 -0
- data/test/regression/test_chart_display_units05.rb +36 -0
- data/test/regression/test_chart_display_units06.rb +36 -0
- data/test/regression/test_chart_display_units07.rb +36 -0
- data/test/regression/test_chart_display_units08.rb +36 -0
- data/test/regression/test_chart_display_units09.rb +36 -0
- data/test/regression/test_chart_display_units10.rb +36 -0
- data/test/regression/test_chart_display_units11.rb +36 -0
- data/test/regression/test_chart_display_units12.rb +41 -0
- data/test/regression/test_chart_gradient01.rb +46 -0
- data/test/regression/test_chart_gradient02.rb +46 -0
- data/test/regression/test_chart_gradient03.rb +49 -0
- data/test/regression/test_chart_gradient04.rb +49 -0
- data/test/regression/test_chart_gradient05.rb +49 -0
- data/test/regression/test_chart_gradient06.rb +49 -0
- data/test/regression/test_chart_gradient07.rb +47 -0
- data/test/regression/test_chart_gradient08.rb +46 -0
- data/test/regression/test_chart_gradient09.rb +46 -0
- data/test/regression/test_chart_gradient10.rb +46 -0
- data/test/regression/test_chart_gradient11.rb +46 -0
- data/test/regression/test_chart_gradient12.rb +49 -0
- data/test/regression/test_chart_gradient13.rb +49 -0
- data/test/regression/test_formula_results01.rb +37 -0
- data/test/regression/test_hyperlink21.rb +24 -0
- data/test/regression/test_merge_range01.rb +27 -0
- data/test/regression/test_merge_range02.rb +27 -0
- data/test/regression/test_merge_range03.rb +29 -0
- data/test/regression/test_merge_range04.rb +27 -0
- data/test/regression/test_merge_range05.rb +27 -0
- data/test/regression/test_print_options07.rb +33 -0
- data/test/regression/xlsx_files/chart_clustered01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units08.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units09.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units11.xlsx +0 -0
- data/test/regression/xlsx_files/chart_display_units12.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient08.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient09.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient11.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient12.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gradient13.xlsx +0 -0
- data/test/regression/xlsx_files/formula_results01.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink21.xlsx +0 -0
- data/test/regression/xlsx_files/merge_range01.xlsx +0 -0
- data/test/regression/xlsx_files/merge_range02.xlsx +0 -0
- data/test/regression/xlsx_files/merge_range03.xlsx +0 -0
- data/test/regression/xlsx_files/merge_range04.xlsx +0 -0
- data/test/regression/xlsx_files/merge_range05.xlsx +0 -0
- data/test/regression/xlsx_files/print_options07.xlsx +0 -0
- data/test/workbook/test_workbook_new.rb +3 -3
- metadata +142 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ef56ba78bc0dc29b679deb80865e971e73c9a7d
|
|
4
|
+
data.tar.gz: 8f59b217f920752fe91ff5291ccb335c0ecc5052
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6228d2653d110defdf4ae1f7c19e0ce8cf868c00ec404a39d081c4f09c1c8bd4894f65d078dce84ba471f9fc382442f000d5f9953d52f0b0afd1031b3078a05d
|
|
7
|
+
data.tar.gz: 409bdff580f1c80d2a457d92d744ec5cca67b16dedfb6614474dd12e3f2867f4e0027a9c2074deb3c4ec262df23668e21aa5baae7c9da547e00dd1ac3239d700
|
data/.travis.yml
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
rvm:
|
|
3
|
+
- 2.3.1
|
|
4
|
+
- 2.3.0
|
|
5
|
+
- 2.2.5
|
|
6
|
+
- 2.2.4
|
|
7
|
+
- 2.2.3
|
|
8
|
+
- 2.2.2
|
|
9
|
+
- 2.2.1
|
|
3
10
|
- 2.2.0
|
|
11
|
+
- 2.1.10
|
|
12
|
+
- 2.1.9
|
|
13
|
+
- 2.1.8
|
|
14
|
+
- 2.1.7
|
|
15
|
+
- 2.1.6
|
|
4
16
|
- 2.1.5
|
|
17
|
+
- 2.1.4
|
|
18
|
+
- 2.1.3
|
|
5
19
|
- 2.1.2
|
|
6
20
|
- 2.1.1
|
|
21
|
+
- 2.1.0
|
|
7
22
|
- 2.0.0
|
|
8
23
|
- 1.9.3
|
data/Changes
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
Change history of write_xlsx rubygem.
|
|
2
|
+
|
|
3
|
+
2017-05-19 v0.85.1
|
|
4
|
+
Fix for missing method Workbook#set_tempdir
|
|
5
|
+
|
|
6
|
+
2016-06-01 v0.85.0
|
|
7
|
+
Fix url encoding of links to external files and dirs.
|
|
8
|
+
|
|
9
|
+
2016-03-11 v0.84.0
|
|
10
|
+
Added support for chart axis display units (thousands, million, etc.).
|
|
11
|
+
Added option to set printing in black and white.
|
|
12
|
+
Added chart styles example.
|
|
13
|
+
Added gradient fill support.
|
|
14
|
+
Added support for clustered charts.
|
|
15
|
+
Added support for boolean error codes.
|
|
16
|
+
|
|
2
17
|
2015-04-12 v0.83.0
|
|
3
18
|
Added option to combine two different chart types. For example to
|
|
4
19
|
create a Pareto chart.
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
gem to create a new file in the Excel 2007+ XLSX format, and you can use the
|
|
7
7
|
same interface as writeexcel gem. write_xlsx is converted from Perl's module
|
|
8
|
-
[Excel::Writer::XLSX-0.
|
|
8
|
+
[Excel::Writer::XLSX-0.84](https://github.com/jmcnamara/excel-writer-xlsx) .
|
|
9
9
|
|
|
10
10
|
## Description
|
|
11
11
|
|
|
@@ -85,7 +85,7 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
|
|
|
85
85
|
Original Perl module was written by John McNamara(jmcnamara@cpan.org).
|
|
86
86
|
|
|
87
87
|
Converted to ruby by Hideo NAKAMURA(cxn03651@msj.biglobe.ne.jp)
|
|
88
|
-
Copyright (c) 2012-
|
|
88
|
+
Copyright (c) 2012-2017 Hideo NAKAMURA.
|
|
89
89
|
|
|
90
90
|
See LICENSE.txt for further details.
|
|
91
91
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# A demo of a clustered category chart in Excel::Writer::XLSX.
|
|
6
|
+
#
|
|
7
|
+
# reverse ('(c)'), March 2015, John McNamara, jmcnamara@cpan.org
|
|
8
|
+
# convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require 'write_xlsx'
|
|
12
|
+
|
|
13
|
+
workbook = WriteXLSX.new('chart_clustered.xlsx')
|
|
14
|
+
worksheet = workbook.add_worksheet
|
|
15
|
+
bold = workbook.add_format(:bold => 1)
|
|
16
|
+
|
|
17
|
+
# Add the worksheet data that the charts will refer to.
|
|
18
|
+
headings = ['Types', 'Sub Type', 'Value 1', 'Value 2', 'Value 3']
|
|
19
|
+
data = [
|
|
20
|
+
['Type 1', 'Sub Type A', 5000, 8000, 6000],
|
|
21
|
+
['', 'Sub Type B', 2000, 3000, 4000],
|
|
22
|
+
['', 'Sub Type C', 250, 1000, 2000],
|
|
23
|
+
['Type 2', 'Sub Type D', 6000, 6000, 6500],
|
|
24
|
+
['', 'Sub Type E', 500, 300, 200]
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
worksheet.write('A1', headings, bold)
|
|
28
|
+
worksheet.write_col('A2', data)
|
|
29
|
+
|
|
30
|
+
# Create a new chart object. In this case an embedded chart.
|
|
31
|
+
chart = workbook.add_chart(:type => 'column', :embedded => 1)
|
|
32
|
+
|
|
33
|
+
# Configure the series. Note, that the categories are 2D ranges (from column A
|
|
34
|
+
# to column B). This creates the clusters. The series are shown as formula
|
|
35
|
+
# strings for clarity but you can also use the array syntax. See the docs.
|
|
36
|
+
chart.add_series(
|
|
37
|
+
:name => '=Sheet1!$C$1',
|
|
38
|
+
:categories => '=Sheet1!$A$2:$B$6',
|
|
39
|
+
:values => '=Sheet1!$C$2:$C$6'
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
chart.add_series(
|
|
43
|
+
:name => '=Sheet1!$D$1',
|
|
44
|
+
:categories => '=Sheet1!$A$2:$B$6',
|
|
45
|
+
:values => '=Sheet1!$D$2:$D$6'
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
chart.add_series(
|
|
49
|
+
:name => '=Sheet1!$E$1',
|
|
50
|
+
:categories => '=Sheet1!$A$2:$B$6',
|
|
51
|
+
:values => '=Sheet1!$E$2:$E$6'
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Set the Excel chart style.
|
|
55
|
+
chart.set_style(37)
|
|
56
|
+
|
|
57
|
+
# Turn off the legend.
|
|
58
|
+
chart.set_legend(:position => 'none')
|
|
59
|
+
|
|
60
|
+
# Insert the chart into the worksheet.
|
|
61
|
+
worksheet.insert_chart('G3', chart)
|
|
62
|
+
|
|
63
|
+
workbook.close
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
#######################################################################
|
|
5
|
+
#
|
|
6
|
+
# An example showing all 48 default chart styles available in Excel 2007
|
|
7
|
+
# using Excel::Writer::XLSX.. Note, these styles are not the same as the
|
|
8
|
+
# styles available in Excel 2013.
|
|
9
|
+
#
|
|
10
|
+
# reverse ('(c)'), March 2015, John McNamara, jmcnamara@cpan.org
|
|
11
|
+
# convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
require 'write_xlsx'
|
|
15
|
+
|
|
16
|
+
workbook = WriteXLSX.new('chart_styles.xlsx')
|
|
17
|
+
|
|
18
|
+
# Show the styles for all of these chart types.
|
|
19
|
+
chart_types = ['column', 'area', 'line', 'pie']
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
chart_types.each do |chart_type|
|
|
23
|
+
# Add a worksheet for each chart type.
|
|
24
|
+
worksheet = workbook.add_worksheet(chart_type.capitalize)
|
|
25
|
+
worksheet.zoom = 30
|
|
26
|
+
style_number = 1
|
|
27
|
+
|
|
28
|
+
# Create 48 charts, each with a different style.
|
|
29
|
+
0.step(89, 15) do |row_num|
|
|
30
|
+
0.step(63, 8) do |col_num|
|
|
31
|
+
chart = workbook.add_chart(
|
|
32
|
+
:type => chart_type,
|
|
33
|
+
:embedded => 1
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
chart.add_series( :values => '=Data!$A$1:$A$6' )
|
|
37
|
+
chart.set_title( :name => "Style #{style_number}" )
|
|
38
|
+
chart.set_legend( :none => 1 )
|
|
39
|
+
chart.set_style( style_number )
|
|
40
|
+
|
|
41
|
+
worksheet.insert_chart(row_num, col_num, chart)
|
|
42
|
+
style_number += 1
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Create a worksheet with data for the charts.
|
|
48
|
+
data = [ 10, 40, 50, 20, 10, 50 ]
|
|
49
|
+
data_worksheet = workbook.add_worksheet('Data')
|
|
50
|
+
data_worksheet.write_col('A1', data)
|
|
51
|
+
data_worksheet.hide
|
|
52
|
+
|
|
53
|
+
workbook.close
|
data/lib/write_xlsx/chart.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
require 'write_xlsx/package/xml_writer_simple'
|
|
3
|
+
require 'write_xlsx/gradient'
|
|
3
4
|
require 'write_xlsx/utility'
|
|
4
5
|
require 'write_xlsx/chart/axis'
|
|
5
6
|
require 'write_xlsx/chart/caption'
|
|
@@ -37,8 +38,9 @@ def attributes
|
|
|
37
38
|
|
|
38
39
|
class ChartArea
|
|
39
40
|
include Writexlsx::Utility
|
|
41
|
+
include Writexlsx::Gradient
|
|
40
42
|
|
|
41
|
-
attr_reader :line, :fill, :layout
|
|
43
|
+
attr_reader :line, :fill, :gradient, :layout
|
|
42
44
|
|
|
43
45
|
def initialize(params = {})
|
|
44
46
|
@layout = layout_properties(params[:layout])
|
|
@@ -49,9 +51,16 @@ def initialize(params = {})
|
|
|
49
51
|
# Set the line properties for the chartarea.
|
|
50
52
|
@line = border ? line_properties(border) : line_properties(params[:line])
|
|
51
53
|
|
|
54
|
+
# Set the gradient fill properties for the series.
|
|
55
|
+
@gradient = gradient_properties(params[:gradient])
|
|
56
|
+
|
|
52
57
|
# Map deprecated Spreadsheet::WriteExcel fill colour.
|
|
53
58
|
fill = params[:color] ? { :color => params[:color] } : params[:fill]
|
|
54
59
|
@fill = fill_properties(fill)
|
|
60
|
+
|
|
61
|
+
if ptrue?(@gradient)
|
|
62
|
+
@fill = nil
|
|
63
|
+
end
|
|
55
64
|
end
|
|
56
65
|
|
|
57
66
|
private
|
|
@@ -641,6 +650,7 @@ def get_data_type(data) # :nodoc:
|
|
|
641
650
|
# Check for no data in the series.
|
|
642
651
|
return 'none' unless data
|
|
643
652
|
return 'none' if data.empty?
|
|
653
|
+
return 'multi_str' if data.first.kind_of?(Array)
|
|
644
654
|
|
|
645
655
|
# If the token isn't a number assume it is a string.
|
|
646
656
|
data.each do |token|
|
|
@@ -1089,6 +1099,10 @@ def write_cat(series) # :nodoc:
|
|
|
1089
1099
|
@cat_has_num_fmt = false
|
|
1090
1100
|
# Write the c:strRef element.
|
|
1091
1101
|
write_str_ref(formula, data, type)
|
|
1102
|
+
elsif type == 'multi_str'
|
|
1103
|
+
@cat_has_num_fmt = false
|
|
1104
|
+
# Write the c:multiLvLStrRef element.
|
|
1105
|
+
write_multi_lvl_str_ref(formula, data)
|
|
1092
1106
|
else
|
|
1093
1107
|
@cat_has_num_fmt = true
|
|
1094
1108
|
# Write the c:numRef element.
|
|
@@ -1146,6 +1160,32 @@ def write_str_ref(formula, data, type) # :nodoc:
|
|
|
1146
1160
|
write_num_or_str_ref('c:strRef', formula, data, type)
|
|
1147
1161
|
end
|
|
1148
1162
|
|
|
1163
|
+
#
|
|
1164
|
+
# Write the <c:multiLvLStrRef> element.
|
|
1165
|
+
#
|
|
1166
|
+
def write_multi_lvl_str_ref(formula, data)
|
|
1167
|
+
return if data.empty?
|
|
1168
|
+
|
|
1169
|
+
@writer.tag_elements('c:multiLvlStrRef') do
|
|
1170
|
+
# Write the c:f element.
|
|
1171
|
+
write_series_formula(formula)
|
|
1172
|
+
|
|
1173
|
+
@writer.tag_elements('c:multiLvlStrCache') do
|
|
1174
|
+
|
|
1175
|
+
# Write the c:ptCount element.
|
|
1176
|
+
write_pt_count(data.last.size)
|
|
1177
|
+
|
|
1178
|
+
# Write the data arrays in reverse order.
|
|
1179
|
+
data.reverse.each do |arr|
|
|
1180
|
+
@writer.tag_elements('c:lvl') do
|
|
1181
|
+
# Write the c:pt element.
|
|
1182
|
+
arr.each_with_index {|a, i| write_pt(i, a)}
|
|
1183
|
+
end
|
|
1184
|
+
end
|
|
1185
|
+
end
|
|
1186
|
+
end
|
|
1187
|
+
end
|
|
1188
|
+
|
|
1149
1189
|
#
|
|
1150
1190
|
# Write the <c:numLit> element for literal number list elements.
|
|
1151
1191
|
#
|
|
@@ -1329,6 +1369,9 @@ def write_val_axis_base(x_axis, y_axis, axis_ids_0, axis_ids_1, position) # :no
|
|
|
1329
1369
|
|
|
1330
1370
|
# Write the c:minorUnit element.
|
|
1331
1371
|
write_c_minor_unit(y_axis.minor_unit)
|
|
1372
|
+
|
|
1373
|
+
# Write the c:dispUnits element.
|
|
1374
|
+
write_disp_units(y_axis.display_units, y_axis.display_units_visible)
|
|
1332
1375
|
end
|
|
1333
1376
|
end
|
|
1334
1377
|
|
|
@@ -2045,11 +2088,12 @@ def write_symbol(val) # :nodoc:
|
|
|
2045
2088
|
# Write the <c:spPr> element.
|
|
2046
2089
|
#
|
|
2047
2090
|
def write_sp_pr(series) # :nodoc:
|
|
2048
|
-
line
|
|
2049
|
-
fill
|
|
2091
|
+
line = series.line
|
|
2092
|
+
fill = series.fill
|
|
2093
|
+
gradient = series.gradient if series.respond_to?(:gradient)
|
|
2050
2094
|
|
|
2051
2095
|
return if (!line || !ptrue?(line[:_defined])) &&
|
|
2052
|
-
(!fill || !ptrue?(fill[:_defined]))
|
|
2096
|
+
(!fill || !ptrue?(fill[:_defined])) && !gradient
|
|
2053
2097
|
|
|
2054
2098
|
@writer.tag_elements('c:spPr') do
|
|
2055
2099
|
# Write the fill elements for solid charts such as pie/doughnut and bar.
|
|
@@ -2062,6 +2106,10 @@ def write_sp_pr(series) # :nodoc:
|
|
|
2062
2106
|
write_a_solid_fill(fill)
|
|
2063
2107
|
end
|
|
2064
2108
|
end
|
|
2109
|
+
if ptrue?(gradient)
|
|
2110
|
+
# Write the a:gradFill element.
|
|
2111
|
+
write_a_grad_fill(gradient)
|
|
2112
|
+
end
|
|
2065
2113
|
# Write the a:ln element.
|
|
2066
2114
|
write_a_ln(line) if line && ptrue?(line[:_defined])
|
|
2067
2115
|
end
|
|
@@ -2642,6 +2690,145 @@ def write_c_smooth(smooth)
|
|
|
2642
2690
|
@writer.empty_tag('c:smooth', attributes)
|
|
2643
2691
|
end
|
|
2644
2692
|
|
|
2693
|
+
#
|
|
2694
|
+
# Write the <c:dispUnits> element.
|
|
2695
|
+
#
|
|
2696
|
+
def write_disp_units(units, display)
|
|
2697
|
+
return unless ptrue?(units)
|
|
2698
|
+
|
|
2699
|
+
attributes = [ ['val', units] ]
|
|
2700
|
+
|
|
2701
|
+
@writer.tag_elements('c:dispUnits') do
|
|
2702
|
+
@writer.empty_tag('c:builtInUnit', attributes)
|
|
2703
|
+
if ptrue?(display)
|
|
2704
|
+
@writer.tag_elements('c:dispUnitsLbl') do
|
|
2705
|
+
@writer.empty_tag('c:layout')
|
|
2706
|
+
end
|
|
2707
|
+
end
|
|
2708
|
+
end
|
|
2709
|
+
end
|
|
2710
|
+
|
|
2711
|
+
#
|
|
2712
|
+
# Write the <a:gradFill> element.
|
|
2713
|
+
#
|
|
2714
|
+
def write_a_grad_fill(gradient)
|
|
2715
|
+
attributes = [
|
|
2716
|
+
['flip', 'none'],
|
|
2717
|
+
['rotWithShape', 1]
|
|
2718
|
+
]
|
|
2719
|
+
attributes = [] if gradient[:type] == 'linear'
|
|
2720
|
+
|
|
2721
|
+
@writer.tag_elements('a:gradFill', attributes) do
|
|
2722
|
+
|
|
2723
|
+
# Write the a:gsLst element.
|
|
2724
|
+
write_a_gs_lst(gradient)
|
|
2725
|
+
|
|
2726
|
+
if gradient[:type] == 'linear'
|
|
2727
|
+
# Write the a:lin element.
|
|
2728
|
+
write_a_lin(gradient[:angle])
|
|
2729
|
+
else
|
|
2730
|
+
# Write the a:path element.
|
|
2731
|
+
write_a_path(gradient[:type])
|
|
2732
|
+
|
|
2733
|
+
# Write the a:tileRect element.
|
|
2734
|
+
write_a_tile_rect(gradient[:type])
|
|
2735
|
+
end
|
|
2736
|
+
end
|
|
2737
|
+
end
|
|
2738
|
+
|
|
2739
|
+
#
|
|
2740
|
+
# Write the <a:gsLst> element.
|
|
2741
|
+
#
|
|
2742
|
+
def write_a_gs_lst(gradient)
|
|
2743
|
+
positions = gradient[:positions]
|
|
2744
|
+
colors = gradient[:colors]
|
|
2745
|
+
|
|
2746
|
+
@writer.tag_elements('a:gsLst') do
|
|
2747
|
+
(0..colors.size-1).each do |i|
|
|
2748
|
+
pos = (positions[i] * 1000).to_i
|
|
2749
|
+
|
|
2750
|
+
attributes = [ ['pos', pos] ]
|
|
2751
|
+
@writer.tag_elements('a:gs', attributes) do
|
|
2752
|
+
|
|
2753
|
+
color = color(colors[i])
|
|
2754
|
+
|
|
2755
|
+
# Write the a:srgbClr element.
|
|
2756
|
+
# TODO: Wait for a feature request to support transparency.
|
|
2757
|
+
write_a_srgb_clr( color );
|
|
2758
|
+
end
|
|
2759
|
+
end
|
|
2760
|
+
end
|
|
2761
|
+
end
|
|
2762
|
+
|
|
2763
|
+
#
|
|
2764
|
+
# Write the <a:lin> element.
|
|
2765
|
+
#
|
|
2766
|
+
def write_a_lin(angle)
|
|
2767
|
+
scaled = 0
|
|
2768
|
+
|
|
2769
|
+
angle = (60000 * angle).to_i
|
|
2770
|
+
|
|
2771
|
+
attributes = [
|
|
2772
|
+
['ang', angle],
|
|
2773
|
+
['scaled', scaled]
|
|
2774
|
+
]
|
|
2775
|
+
|
|
2776
|
+
@writer.empty_tag('a:lin', attributes)
|
|
2777
|
+
end
|
|
2778
|
+
|
|
2779
|
+
#
|
|
2780
|
+
# Write the <a:path> element.
|
|
2781
|
+
#
|
|
2782
|
+
def write_a_path(type)
|
|
2783
|
+
attributes = [ ['path', type] ]
|
|
2784
|
+
|
|
2785
|
+
@writer.tag_elements('a:path', attributes) do
|
|
2786
|
+
# Write the a:fillToRect element.
|
|
2787
|
+
write_a_fill_to_rect(type)
|
|
2788
|
+
end
|
|
2789
|
+
end
|
|
2790
|
+
|
|
2791
|
+
#
|
|
2792
|
+
# Write the <a:fillToRect> element.
|
|
2793
|
+
#
|
|
2794
|
+
def write_a_fill_to_rect(type)
|
|
2795
|
+
attributes = []
|
|
2796
|
+
|
|
2797
|
+
if type == 'shape'
|
|
2798
|
+
attributes = [
|
|
2799
|
+
['l' , 50000],
|
|
2800
|
+
['t' , 50000],
|
|
2801
|
+
['r' , 50000],
|
|
2802
|
+
['b' , 50000]
|
|
2803
|
+
]
|
|
2804
|
+
else
|
|
2805
|
+
attributes = [
|
|
2806
|
+
['l', 100000],
|
|
2807
|
+
['t', 100000]
|
|
2808
|
+
]
|
|
2809
|
+
end
|
|
2810
|
+
|
|
2811
|
+
@writer.empty_tag('a:fillToRect', attributes)
|
|
2812
|
+
end
|
|
2813
|
+
|
|
2814
|
+
#
|
|
2815
|
+
# Write the <a:tileRect> element.
|
|
2816
|
+
#
|
|
2817
|
+
def write_a_tile_rect(type)
|
|
2818
|
+
attributes = []
|
|
2819
|
+
|
|
2820
|
+
if type == 'shape'
|
|
2821
|
+
attributes = []
|
|
2822
|
+
else
|
|
2823
|
+
attributes = [
|
|
2824
|
+
['r', -100000],
|
|
2825
|
+
['b', -100000]
|
|
2826
|
+
]
|
|
2827
|
+
end
|
|
2828
|
+
|
|
2829
|
+
@writer.empty_tag('a:tileRect', attributes)
|
|
2830
|
+
end
|
|
2831
|
+
|
|
2645
2832
|
def write_bars_base(tag, format)
|
|
2646
2833
|
if format.line_defined? || format.fill_defined?
|
|
2647
2834
|
@writer.tag_elements(tag) { write_sp_pr(format) }
|