write_xlsx 0.81.1 → 0.83.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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/Changes +20 -0
- data/README.md +3 -2
- data/examples/chart_combined.rb +107 -0
- data/examples/chart_data_table.rb +1 -1
- data/examples/chart_pareto.rb +82 -0
- data/lib/write_xlsx/chart.rb +115 -42
- data/lib/write_xlsx/chart/axis.rb +5 -1
- data/lib/write_xlsx/chart/bar.rb +13 -0
- data/lib/write_xlsx/chart/pie.rb +7 -0
- data/lib/write_xlsx/chart/scatter.rb +25 -57
- data/lib/write_xlsx/format.rb +40 -0
- data/lib/write_xlsx/package/app.rb +39 -1
- data/lib/write_xlsx/package/comments.rb +1 -5
- data/lib/write_xlsx/package/content_types.rb +48 -13
- data/lib/write_xlsx/package/core.rb +14 -12
- data/lib/write_xlsx/package/packager.rb +17 -41
- data/lib/write_xlsx/package/styles.rb +215 -256
- data/lib/write_xlsx/package/table.rb +5 -7
- data/lib/write_xlsx/package/xml_writer_simple.rb +2 -0
- data/lib/write_xlsx/sheets.rb +2 -2
- data/lib/write_xlsx/utility.rb +17 -2
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +44 -2
- data/lib/write_xlsx/worksheet.rb +26 -17
- data/lib/write_xlsx/worksheet/page_setup.rb +12 -6
- data/test/chart/test_write_style.rb +2 -2
- data/test/helper.rb +3 -0
- data/test/package/app/test_app01.rb +1 -1
- data/test/package/app/test_app02.rb +1 -1
- data/test/package/app/test_app03.rb +1 -1
- data/test/package/content_types/test_content_types.rb +1 -1
- data/test/package/content_types/test_write_default.rb +1 -1
- data/test/package/content_types/test_write_override.rb +1 -1
- data/test/perl_output/chart_combined.xlsx +0 -0
- data/test/perl_output/chart_pareto.xlsx +0 -0
- data/test/regression/test_button07.rb +5 -2
- data/test/regression/test_button13.rb +34 -0
- data/test/regression/test_button14.rb +31 -0
- data/test/regression/test_chart_column11.rb +45 -0
- data/test/regression/test_chart_column12.rb +45 -0
- data/test/regression/test_chart_combined01.rb +37 -0
- data/test/regression/test_chart_combined02.rb +43 -0
- data/test/regression/test_chart_combined03.rb +45 -0
- data/test/regression/test_chart_combined04.rb +47 -0
- data/test/regression/test_chart_combined05.rb +49 -0
- data/test/regression/test_chart_combined06.rb +49 -0
- data/test/regression/test_chart_combined07.rb +53 -0
- data/test/regression/test_chart_combined08.rb +65 -0
- data/test/regression/test_chart_data_labels24.rb +50 -0
- data/test/regression/test_chart_date05.rb +57 -0
- data/test/regression/test_chart_format20.rb +55 -0
- data/test/regression/test_format11.rb +28 -0
- data/test/regression/test_format12.rb +41 -0
- data/test/regression/test_landscape01.rb +27 -0
- data/test/regression/test_quote_name04.rb +40 -0
- data/test/regression/test_set_start_page01.rb +4 -7
- data/test/regression/test_set_start_page02.rb +33 -0
- data/test/regression/test_set_start_page03.rb +33 -0
- data/test/regression/test_table17.rb +70 -0
- data/test/regression/xlsx_files/chart_column11.xlsx +0 -0
- data/test/regression/xlsx_files/chart_column12.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_combined08.xlsx +0 -0
- data/test/regression/xlsx_files/chart_date05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format20.xlsx +0 -0
- data/test/regression/xlsx_files/format11.xlsx +0 -0
- data/test/regression/xlsx_files/format12.xlsx +0 -0
- data/test/regression/xlsx_files/landscape01.xlsx +0 -0
- data/test/regression/xlsx_files/quote_name04.xlsx +0 -0
- data/test/regression/xlsx_files/set_start_page01.xlsx +0 -0
- data/test/regression/xlsx_files/set_start_page02.xlsx +0 -0
- data/test/regression/xlsx_files/set_start_page03.xlsx +0 -0
- data/test/regression/xlsx_files/table17.xlsx +0 -0
- data/test/test_example_match.rb +172 -0
- data/write_xlsx.gemspec +1 -0
- metadata +106 -3
@@ -101,10 +101,8 @@ def overrite_the_defaults_with_any_use_defined_values(col_id, col_data, col_num)
|
|
101
101
|
# Handle the function for the total row.
|
102
102
|
if user_data[:total_function]
|
103
103
|
handle_the_function_for_the_table_row(
|
104
|
-
|
105
|
-
|
106
|
-
user_data[:format]
|
107
|
-
)
|
104
|
+
@row2, col_data, col_num, user_data
|
105
|
+
)
|
108
106
|
elsif user_data[:total_string]
|
109
107
|
total_label_only(
|
110
108
|
@row2, col_num, col_data, user_data[:total_string], user_data[:format]
|
@@ -212,8 +210,8 @@ def handle_the_column_formula(col_data, col_num, formula, format)
|
|
212
210
|
end
|
213
211
|
end
|
214
212
|
|
215
|
-
def handle_the_function_for_the_table_row(row2, col_data, col_num,
|
216
|
-
function = total_function.downcase.gsub(/[_\s]/, '')
|
213
|
+
def handle_the_function_for_the_table_row(row2, col_data, col_num, user_data)
|
214
|
+
function = user_data[:total_function].downcase.gsub(/[_\s]/, '')
|
217
215
|
|
218
216
|
function = 'countNums' if function == 'countnums'
|
219
217
|
function = 'stdDev' if function == 'stddev'
|
@@ -221,7 +219,7 @@ def handle_the_function_for_the_table_row(row2, col_data, col_num, total_functio
|
|
221
219
|
col_data.total_function = function
|
222
220
|
|
223
221
|
formula = table_function_to_formula(function, col_data.name)
|
224
|
-
@worksheet.write_formula(row2, col_num, formula, format)
|
222
|
+
@worksheet.write_formula(row2, col_num, formula, user_data[:format], user_data[:total_value])
|
225
223
|
end
|
226
224
|
|
227
225
|
#
|
data/lib/write_xlsx/sheets.rb
CHANGED
@@ -197,8 +197,6 @@ def index_by_name(sheetname)
|
|
197
197
|
self.collect { |sheet| sheet.name }.index(name)
|
198
198
|
end
|
199
199
|
|
200
|
-
private
|
201
|
-
|
202
200
|
def worksheets
|
203
201
|
self.reject { |worksheet| worksheet.is_chartsheet? }
|
204
202
|
end
|
@@ -207,6 +205,8 @@ def chartsheets
|
|
207
205
|
self.select { |worksheet| worksheet.is_chartsheet? }
|
208
206
|
end
|
209
207
|
|
208
|
+
private
|
209
|
+
|
210
210
|
def sheet_chart_count(type)
|
211
211
|
case type
|
212
212
|
when :sheet
|
data/lib/write_xlsx/utility.rb
CHANGED
@@ -13,8 +13,6 @@ module Utility
|
|
13
13
|
#
|
14
14
|
def xl_rowcol_to_cell(row, col, row_absolute = false, col_absolute = false)
|
15
15
|
row += 1 # Change from 0-indexed to 1 indexed.
|
16
|
-
row_abs = row_absolute ? '$' : ''
|
17
|
-
col_abs = col_absolute ? '$' : ''
|
18
16
|
col_str = xl_col_to_name(col, col_absolute)
|
19
17
|
"#{col_str}#{absolute_char(row_absolute)}#{row}"
|
20
18
|
end
|
@@ -75,6 +73,23 @@ def xl_range_formula(sheetname, row_1, row_2, col_1, col_2)
|
|
75
73
|
"=#{sheetname}!#{range1}:#{range2}"
|
76
74
|
end
|
77
75
|
|
76
|
+
#
|
77
|
+
# Sheetnames used in references should be quoted if they contain any spaces,
|
78
|
+
# special characters or if the look like something that isn't a sheet name.
|
79
|
+
# TODO. We need to handle more special cases.
|
80
|
+
#
|
81
|
+
def quote_sheetname(sheetname) #:nodoc:
|
82
|
+
# Use Excel's conventions and quote the sheet name if it comtains any
|
83
|
+
# non-word character or if it isn't already quoted.
|
84
|
+
name = sheetname.dup
|
85
|
+
if name =~ /\W/ && !(name =~ /^'/)
|
86
|
+
# Double quote and single quoted strings.
|
87
|
+
name = name.gsub(/'/, "''")
|
88
|
+
name = "'#{name}'"
|
89
|
+
end
|
90
|
+
name
|
91
|
+
end
|
92
|
+
|
78
93
|
def check_dimensions(row, col)
|
79
94
|
if !row || row >= ROW_MAX || !col || col >= COL_MAX
|
80
95
|
raise WriteXLSXDimensionError
|
data/lib/write_xlsx/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WriteXLSX_VERSION = "0.
|
1
|
+
WriteXLSX_VERSION = "0.83.0"
|
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -833,6 +833,17 @@ def add_vba_project(vba_project)
|
|
833
833
|
@vba_project = vba_project
|
834
834
|
end
|
835
835
|
|
836
|
+
#
|
837
|
+
# Set the VBA name for the workbook.
|
838
|
+
#
|
839
|
+
def set_vba_name(vba_codename = nil)
|
840
|
+
if vba_codename
|
841
|
+
@vba_codename = vba_codename
|
842
|
+
else
|
843
|
+
@vba_codename = 'ThisWorkbook'
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
836
847
|
#
|
837
848
|
# set_calc_mode()
|
838
849
|
#
|
@@ -971,6 +982,10 @@ def chartsheet_count
|
|
971
982
|
@worksheets.chartsheet_count
|
972
983
|
end
|
973
984
|
|
985
|
+
def non_chartsheet_count
|
986
|
+
@worksheets.worksheets.count
|
987
|
+
end
|
988
|
+
|
974
989
|
def style_properties
|
975
990
|
[
|
976
991
|
@xf_formats,
|
@@ -992,6 +1007,14 @@ def num_comment_files
|
|
992
1007
|
@worksheets.select { |sheet| sheet.has_comments? }.count
|
993
1008
|
end
|
994
1009
|
|
1010
|
+
def chartsheets
|
1011
|
+
@worksheets.chartsheets
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
def non_chartsheets
|
1015
|
+
@worksheets.worksheets
|
1016
|
+
end
|
1017
|
+
|
995
1018
|
private
|
996
1019
|
|
997
1020
|
def setup_filename(file) #:nodoc:
|
@@ -1537,6 +1560,7 @@ def prepare_vml_objects #:nodoc:
|
|
1537
1560
|
vml_header_id = 0
|
1538
1561
|
vml_shape_id = 1024
|
1539
1562
|
comment_files = 0
|
1563
|
+
has_button = false
|
1540
1564
|
|
1541
1565
|
@worksheets.each do |sheet|
|
1542
1566
|
next if !sheet.has_vml? && !sheet.has_header_vml?
|
@@ -1560,9 +1584,24 @@ def prepare_vml_objects #:nodoc:
|
|
1560
1584
|
vml_drawing_id += 1
|
1561
1585
|
sheet.prepare_header_vml_objects(vml_header_id, vml_drawing_id)
|
1562
1586
|
end
|
1587
|
+
|
1588
|
+
# Set the sheet vba_codename if it has a button and the workbook
|
1589
|
+
# has a vbaProject binary.
|
1590
|
+
unless sheet.buttons_data.empty?
|
1591
|
+
has_button = true
|
1592
|
+
if @vba_project && !sheet.vba_codename
|
1593
|
+
sheet.set_vba_name
|
1594
|
+
end
|
1595
|
+
end
|
1563
1596
|
end
|
1564
1597
|
|
1565
1598
|
add_font_format_for_cell_comments if num_comment_files > 0
|
1599
|
+
|
1600
|
+
# Set the workbook vba_codename if one of the sheets has a button and
|
1601
|
+
# the workbook has a vbaProject binary.
|
1602
|
+
if has_button && @vba_project && !@vba_codename
|
1603
|
+
set_vba_name
|
1604
|
+
end
|
1566
1605
|
end
|
1567
1606
|
|
1568
1607
|
#
|
@@ -1600,7 +1639,9 @@ def add_chart_data #:nodoc:
|
|
1600
1639
|
# Map worksheet names to worksheet objects.
|
1601
1640
|
@worksheets.each { |worksheet| worksheets[worksheet.name] = worksheet }
|
1602
1641
|
|
1603
|
-
|
1642
|
+
# Build an array of the worksheet charts including any combined charts.
|
1643
|
+
@charts.collect { |chart| [chart, chart.combined] }.flatten.compact.
|
1644
|
+
each do |chart|
|
1604
1645
|
chart.formula_ids.each do |range, id|
|
1605
1646
|
# Skip if the series has user defined data.
|
1606
1647
|
if chart.formula_data[id]
|
@@ -1811,7 +1852,8 @@ def prepare_drawings #:nodoc:
|
|
1811
1852
|
|
1812
1853
|
# Sort the workbook charts references into the order that the were
|
1813
1854
|
# written from the worksheets above.
|
1814
|
-
@charts = @charts.
|
1855
|
+
@charts = @charts.select { |chart| chart.id != -1 }.
|
1856
|
+
sort_by { |chart| chart.id }
|
1815
1857
|
|
1816
1858
|
@drawing_count = drawing_id
|
1817
1859
|
end
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -2877,6 +2877,13 @@ def insert_chart(*args)
|
|
2877
2877
|
raise "Not a Chart object in insert_chart()" unless chart.is_a?(Chart) || chart.is_a?(Chartsheet)
|
2878
2878
|
raise "Not a embedded style Chart object in insert_chart()" if chart.respond_to?(:embedded) && chart.embedded == 0
|
2879
2879
|
|
2880
|
+
if chart.already_inserted? || (chart.combined && chart.combined.already_inserted?)
|
2881
|
+
raise "Chart cannot be inserted in a worksheet more than once"
|
2882
|
+
else
|
2883
|
+
chart.already_inserted = true
|
2884
|
+
chart.combined.already_inserted = true if chart.combined
|
2885
|
+
end
|
2886
|
+
|
2880
2887
|
# Use the values set with chart.set_size, if any.
|
2881
2888
|
x_scale = chart.x_scale if chart.x_scale != 1
|
2882
2889
|
y_scale = chart.y_scale if chart.y_scale != 1
|
@@ -5871,6 +5878,25 @@ def tables_count
|
|
5871
5878
|
@tables.size
|
5872
5879
|
end
|
5873
5880
|
|
5881
|
+
def horizontal_dpi=(val)
|
5882
|
+
@page_setup.horizontal_dpi = val
|
5883
|
+
end
|
5884
|
+
|
5885
|
+
def vertical_dpi=(val)
|
5886
|
+
@page_setup.vertical_dpi = val
|
5887
|
+
end
|
5888
|
+
|
5889
|
+
#
|
5890
|
+
# set the vba name for the worksheet
|
5891
|
+
#
|
5892
|
+
def set_vba_name(vba_codename = nil)
|
5893
|
+
if vba_codename
|
5894
|
+
@vba_codename = vba_codename
|
5895
|
+
else
|
5896
|
+
@vba_codename = @name
|
5897
|
+
end
|
5898
|
+
end
|
5899
|
+
|
5874
5900
|
private
|
5875
5901
|
|
5876
5902
|
def hyperlinks_count
|
@@ -7518,23 +7544,6 @@ def convert_name_area(row_num_1, col_num_1, row_num_2, col_num_2) #:nodoc:
|
|
7518
7544
|
"#{quote_sheetname(@name)}!#{area}"
|
7519
7545
|
end
|
7520
7546
|
|
7521
|
-
#
|
7522
|
-
# Sheetnames used in references should be quoted if they contain any spaces,
|
7523
|
-
# special characters or if the look like something that isn't a sheet name.
|
7524
|
-
# TODO. We need to handle more special cases.
|
7525
|
-
#
|
7526
|
-
def quote_sheetname(sheetname) #:nodoc:
|
7527
|
-
# Use Excel's conventions and quote the sheet name if it comtains any
|
7528
|
-
# non-word character or if it isn't already quoted.
|
7529
|
-
name = sheetname.dup
|
7530
|
-
if name =~ /\W/ && !(name =~ /^'/)
|
7531
|
-
# Double quote and single quoted strings.
|
7532
|
-
name = name.gsub(/'/, "''")
|
7533
|
-
name = "'#{name}'"
|
7534
|
-
end
|
7535
|
-
name
|
7536
|
-
end
|
7537
|
-
|
7538
7547
|
def fit_page? #:nodoc:
|
7539
7548
|
@page_setup.fit_page
|
7540
7549
|
end
|
@@ -14,6 +14,7 @@ class PageSetup # :nodoc:
|
|
14
14
|
attr_accessor :orientation, :print_options_changed # :nodoc:
|
15
15
|
attr_accessor :header, :footer, :header_footer_changed, :header_footer_aligns, :header_footer_scales
|
16
16
|
attr_writer :page_start
|
17
|
+
attr_writer :horizontal_dpi, :vertical_dpi
|
17
18
|
|
18
19
|
def initialize # :nodoc:
|
19
20
|
@margin_left = 0.7
|
@@ -97,11 +98,12 @@ def write_page_setup(writer) #:nodoc:
|
|
97
98
|
return unless @page_setup_changed
|
98
99
|
|
99
100
|
attributes = []
|
100
|
-
attributes << ['paperSize',
|
101
|
-
attributes << ['scale',
|
102
|
-
attributes << ['fitToWidth',
|
103
|
-
attributes << ['fitToHeight',
|
104
|
-
attributes << ['pageOrder',
|
101
|
+
attributes << ['paperSize', @paper_size] if @paper_size
|
102
|
+
attributes << ['scale', @scale] if @scale != 100
|
103
|
+
attributes << ['fitToWidth', @fit_width] if @fit_page && @fit_width != 1
|
104
|
+
attributes << ['fitToHeight', @fit_height] if @fit_page && @fit_height != 1
|
105
|
+
attributes << ['pageOrder', "overThenDown"] if @across
|
106
|
+
attributes << ['firstPageNumber', @page_start] if @page_start && @page_start > 1
|
105
107
|
attributes << ['orientation',
|
106
108
|
if @orientation
|
107
109
|
'portrait'
|
@@ -109,7 +111,11 @@ def write_page_setup(writer) #:nodoc:
|
|
109
111
|
'landscape'
|
110
112
|
end
|
111
113
|
]
|
112
|
-
attributes << ['useFirstPageNumber',
|
114
|
+
attributes << ['useFirstPageNumber', 1] if ptrue?(@page_start)
|
115
|
+
|
116
|
+
# Set the DPI. Mainly only for testing.
|
117
|
+
attributes << ['horizontalDpi', @horizontal_dpi] if @horizontal_dpi
|
118
|
+
attributes << ['verticalDpi', @vertical_dpi] if @vertical_dpi
|
113
119
|
|
114
120
|
writer.empty_tag('pageSetup', attributes)
|
115
121
|
end
|
@@ -31,9 +31,9 @@ def test_write_style_with_outside_range
|
|
31
31
|
assert_equal(expected, result)
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def test_write_style_with_outside_range_49
|
35
35
|
expected = ''
|
36
|
-
@chart.set_style(
|
36
|
+
@chart.set_style(49)
|
37
37
|
@chart.__send__('write_style')
|
38
38
|
result = @chart.instance_variable_get(:@writer).string
|
39
39
|
assert_equal(expected, result)
|
data/test/helper.rb
CHANGED
@@ -133,6 +133,9 @@ def compare_xlsx(exp_filename, got_filename, ignore_members = nil, ignore_elemen
|
|
133
133
|
sub(/verticalDpi="200" /, '').
|
134
134
|
sub(/(<pageSetup[^>]* )r:id="rId1"/, '\1').
|
135
135
|
sub(/ +\/>/, ' />')
|
136
|
+
got_xml_str = got_xml_str.
|
137
|
+
sub(/horizontalDpi="200" /, '').
|
138
|
+
sub(/verticalDpi="200" /, '')
|
136
139
|
end
|
137
140
|
|
138
141
|
# Remove Chart pageMargin dimensions which are almost always different.
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
class TestApp03 < Test::Unit::TestCase
|
6
6
|
def test_assemble_xml_file
|
7
|
-
@obj = Writexlsx::Package::App.new
|
7
|
+
@obj = Writexlsx::Package::App.new(nil)
|
8
8
|
@obj.add_part_name('Sheet1')
|
9
9
|
@obj.add_part_name('Sheet1!Print_Titles')
|
10
10
|
@obj.add_heading_pair(['Worksheets', 1])
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
class TestContentTypes < Test::Unit::TestCase
|
6
6
|
def test_assemble_xml_file
|
7
|
-
@obj = Writexlsx::Package::ContentTypes.new
|
7
|
+
@obj = Writexlsx::Package::ContentTypes.new(nil)
|
8
8
|
@obj.add_worksheet_name('sheet1')
|
9
9
|
@obj.add_default('jpeg', 'image/jpeg')
|
10
10
|
@obj.add_shared_strings
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
class TestWriteDefault < Test::Unit::TestCase
|
6
6
|
def test_assemble_xml_file
|
7
|
-
@obj = Writexlsx::Package::ContentTypes.new
|
7
|
+
@obj = Writexlsx::Package::ContentTypes.new(nil)
|
8
8
|
@obj.__send__('write_default', 'xml', 'application/xml')
|
9
9
|
result = @obj.xml_str
|
10
10
|
expected = '<Default Extension="xml" ContentType="application/xml"/>'
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
class TestWriteOverride < Test::Unit::TestCase
|
6
6
|
def test_assemble_xml_file
|
7
|
-
@obj = Writexlsx::Package::ContentTypes.new
|
7
|
+
@obj = Writexlsx::Package::ContentTypes.new(nil)
|
8
8
|
@obj.__send__('write_override', '/docProps/core.xml', 'app...')
|
9
9
|
result = @obj.xml_str
|
10
10
|
expected = '<Override PartName="/docProps/core.xml" ContentType="app..."/>'
|
Binary file
|
Binary file
|
@@ -15,8 +15,11 @@ def test_button07
|
|
15
15
|
workbook = WriteXLSX.new(@xlsx)
|
16
16
|
worksheet = workbook.add_worksheet
|
17
17
|
|
18
|
-
workbook.
|
19
|
-
worksheet.
|
18
|
+
workbook.set_vba_name('ThisWorkbook')
|
19
|
+
worksheet.set_vba_name('Sheet1')
|
20
|
+
|
21
|
+
workbook.set_vba_name
|
22
|
+
worksheet.set_vba_name
|
20
23
|
|
21
24
|
worksheet.insert_button('C2', {
|
22
25
|
:macro => 'say_hello',
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionButton13 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_button13
|
14
|
+
@xlsx = 'button07.xlsm'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
|
18
|
+
workbook.set_vba_name
|
19
|
+
worksheet.set_vba_name
|
20
|
+
|
21
|
+
worksheet.insert_button(
|
22
|
+
'C2',
|
23
|
+
{
|
24
|
+
:macro => 'say_hello',
|
25
|
+
:caption => 'Hello'
|
26
|
+
}
|
27
|
+
)
|
28
|
+
|
29
|
+
workbook.add_vba_project(File.join(@regression_output, 'vbaProject02.bin'))
|
30
|
+
|
31
|
+
workbook.close
|
32
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionButton14 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_button14
|
14
|
+
@xlsx = 'button07.xlsm'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
|
18
|
+
worksheet.insert_button(
|
19
|
+
'C2',
|
20
|
+
{
|
21
|
+
:macro => 'say_hello',
|
22
|
+
:caption => 'Hello'
|
23
|
+
}
|
24
|
+
)
|
25
|
+
|
26
|
+
workbook.add_vba_project(File.join(@regression_output, 'vbaProject02.bin'))
|
27
|
+
|
28
|
+
workbook.close
|
29
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
30
|
+
end
|
31
|
+
end
|