write_xlsx 0.58.0 → 0.59.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -1
- data/bin/extract_vba.rb +29 -0
- data/examples/add_vba_project.rb +36 -0
- data/examples/vbaProject.bin +0 -0
- data/lib/write_xlsx/chart.rb +22 -37
- data/lib/write_xlsx/package/conditional_format.rb +593 -0
- data/lib/write_xlsx/package/content_types.rb +17 -0
- data/lib/write_xlsx/package/packager.rb +26 -6
- data/lib/write_xlsx/package/relationships.rb +11 -1
- data/lib/write_xlsx/package/table.rb +284 -62
- data/lib/write_xlsx/utility.rb +179 -0
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +14 -1
- data/lib/write_xlsx/worksheet.rb +667 -875
- data/test/package/table/test_table01.rb +1 -2
- data/test/package/table/test_table02.rb +1 -2
- data/test/package/table/test_table03.rb +1 -2
- data/test/package/table/test_table04.rb +1 -2
- data/test/package/table/test_table05.rb +1 -2
- data/test/package/table/test_table06.rb +1 -2
- data/test/package/table/test_table07.rb +1 -2
- data/test/package/table/test_table08.rb +1 -2
- data/test/package/table/test_table09.rb +1 -2
- data/test/package/table/test_table10.rb +1 -2
- data/test/package/table/test_table11.rb +1 -2
- data/test/package/table/test_table12.rb +1 -2
- data/test/package/table/test_write_auto_filter.rb +10 -3
- data/test/package/table/test_write_table_column.rb +9 -2
- data/test/package/table/test_write_table_style_info.rb +12 -11
- data/test/package/table/test_write_xml_declaration.rb +6 -1
- data/test/perl_output/add_vba_project.xlsm +0 -0
- data/test/regression/test_macro01.rb +29 -0
- data/test/regression/xlsx_files/macro01.xlsm +0 -0
- data/test/regression/xlsx_files/vbaProject01.bin +0 -0
- data/test/test_example_match.rb +22 -0
- data/test/vbaProject.bin +0 -0
- metadata +18 -3
@@ -13,8 +13,7 @@ class TestTable01 < Test::Unit::TestCase
|
|
13
13
|
# Set the table properties.
|
14
14
|
@worksheet.add_table('C3:F13')
|
15
15
|
|
16
|
-
table =
|
17
|
-
table.properties = @worksheet.tables[0]
|
16
|
+
table = @worksheet.tables[0]
|
18
17
|
table.__send__(:assemble_xml_file)
|
19
18
|
|
20
19
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -13,8 +13,7 @@ class TestTable02 < Test::Unit::TestCase
|
|
13
13
|
# Set the table properties.
|
14
14
|
@worksheet.add_table('D4:I15', :style => 'Table Style Light 17')
|
15
15
|
|
16
|
-
table =
|
17
|
-
table.properties = @worksheet.tables[0]
|
16
|
+
table = @worksheet.tables[0]
|
18
17
|
table.__send__(:assemble_xml_file)
|
19
18
|
|
20
19
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -21,8 +21,7 @@ class TestTable03 < Test::Unit::TestCase
|
|
21
21
|
}
|
22
22
|
)
|
23
23
|
|
24
|
-
table =
|
25
|
-
table.properties = @worksheet.tables[0]
|
24
|
+
table = @worksheet.tables[0]
|
26
25
|
table.__send__(:assemble_xml_file)
|
27
26
|
|
28
27
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -18,8 +18,7 @@ class TestTable04 < Test::Unit::TestCase
|
|
18
18
|
}
|
19
19
|
)
|
20
20
|
|
21
|
-
table =
|
22
|
-
table.properties = @worksheet.tables[0]
|
21
|
+
table = @worksheet.tables[0]
|
23
22
|
table.__send__(:assemble_xml_file)
|
24
23
|
|
25
24
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -18,8 +18,7 @@ class TestTable05 < Test::Unit::TestCase
|
|
18
18
|
}
|
19
19
|
)
|
20
20
|
|
21
|
-
table =
|
22
|
-
table.properties = @worksheet.tables[0]
|
21
|
+
table = @worksheet.tables[0]
|
23
22
|
table.__send__(:assemble_xml_file)
|
24
23
|
|
25
24
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -23,8 +23,7 @@ class TestTable06 < Test::Unit::TestCase
|
|
23
23
|
}
|
24
24
|
)
|
25
25
|
|
26
|
-
table =
|
27
|
-
table.properties = @worksheet.tables[0]
|
26
|
+
table = @worksheet.tables[0]
|
28
27
|
table.__send__(:assemble_xml_file)
|
29
28
|
|
30
29
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -18,8 +18,7 @@ class TestTable07 < Test::Unit::TestCase
|
|
18
18
|
}
|
19
19
|
)
|
20
20
|
|
21
|
-
table =
|
22
|
-
table.properties = @worksheet.tables[0]
|
21
|
+
table = @worksheet.tables[0]
|
23
22
|
table.__send__(:assemble_xml_file)
|
24
23
|
|
25
24
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -24,8 +24,7 @@ class TestTable08 < Test::Unit::TestCase
|
|
24
24
|
}
|
25
25
|
)
|
26
26
|
|
27
|
-
table =
|
28
|
-
table.properties = @worksheet.tables[0]
|
27
|
+
table = @worksheet.tables[0]
|
29
28
|
table.__send__(:assemble_xml_file)
|
30
29
|
|
31
30
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -30,8 +30,7 @@ class TestTable09 < Test::Unit::TestCase
|
|
30
30
|
}
|
31
31
|
)
|
32
32
|
|
33
|
-
table =
|
34
|
-
table.properties = @worksheet.tables[0]
|
33
|
+
table = @worksheet.tables[0]
|
35
34
|
table.__send__(:assemble_xml_file)
|
36
35
|
|
37
36
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -16,8 +16,7 @@ class TestTable10 < Test::Unit::TestCase
|
|
16
16
|
{:name => 'MyTable'}
|
17
17
|
)
|
18
18
|
|
19
|
-
table =
|
20
|
-
table.properties = @worksheet.tables[0]
|
19
|
+
table = @worksheet.tables[0]
|
21
20
|
table.__send__(:assemble_xml_file)
|
22
21
|
|
23
22
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -29,8 +29,7 @@ class TestTable11 < Test::Unit::TestCase
|
|
29
29
|
}
|
30
30
|
)
|
31
31
|
|
32
|
-
table =
|
33
|
-
table.properties = @worksheet.tables[0]
|
32
|
+
table = @worksheet.tables[0]
|
34
33
|
table.__send__(:assemble_xml_file)
|
35
34
|
|
36
35
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -29,8 +29,7 @@ class TestTable12 < Test::Unit::TestCase
|
|
29
29
|
}
|
30
30
|
)
|
31
31
|
|
32
|
-
table =
|
33
|
-
table.properties = @worksheet.tables[0]
|
32
|
+
table = @worksheet.tables[0]
|
34
33
|
table.__send__(:assemble_xml_file)
|
35
34
|
|
36
35
|
result = got_to_array(table.instance_variable_get(:@writer).string)
|
@@ -1,13 +1,20 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'helper'
|
3
|
-
require 'write_xlsx
|
3
|
+
require 'write_xlsx'
|
4
|
+
require 'stringio'
|
4
5
|
|
5
6
|
class TestTableWriteAutoFilter01 < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
workbook = WriteXLSX.new(StringIO.new)
|
9
|
+
@worksheet = workbook.add_worksheet
|
10
|
+
end
|
11
|
+
|
6
12
|
def test_table_write_auto_filter
|
7
13
|
expected = '<autoFilter ref="C3:F13"/>'
|
8
14
|
|
9
|
-
table = Writexlsx::Package::Table.new
|
10
|
-
table.
|
15
|
+
table = Writexlsx::Package::Table.new(@worksheet, 0, 1, 1, 2, 2)
|
16
|
+
table.instance_variable_set(:@autofilter, 'C3:F13')
|
17
|
+
|
11
18
|
table.__send__(:write_auto_filter)
|
12
19
|
result = table.instance_variable_get(:@writer).string
|
13
20
|
|
@@ -3,11 +3,18 @@ require 'helper'
|
|
3
3
|
require 'write_xlsx/package/table'
|
4
4
|
|
5
5
|
class TestTableWriteTableColumn < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
workbook = WriteXLSX.new(StringIO.new)
|
8
|
+
@worksheet = workbook.add_worksheet
|
9
|
+
end
|
10
|
+
|
6
11
|
def test_table_write_table_column
|
7
12
|
expected = '<tableColumn id="1" name="Column1"/>'
|
8
13
|
|
9
|
-
table = Writexlsx::Package::Table.new
|
10
|
-
|
14
|
+
table = Writexlsx::Package::Table.new(@worksheet, 0, 1, 1, 2, 2)
|
15
|
+
col_data = Writexlsx::Package::Table::ColumnData.new(1)
|
16
|
+
|
17
|
+
table.__send__(:write_table_column, col_data)
|
11
18
|
result = table.instance_variable_get(:@writer).string
|
12
19
|
|
13
20
|
assert_equal(expected, result)
|
@@ -3,20 +3,21 @@ require 'helper'
|
|
3
3
|
require 'write_xlsx/package/table'
|
4
4
|
|
5
5
|
class TestTableWriteTableStyleInfo < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
workbook = WriteXLSX.new(StringIO.new)
|
8
|
+
@worksheet = workbook.add_worksheet
|
9
|
+
end
|
10
|
+
|
6
11
|
def test_table_write_table_style_info
|
7
12
|
expected = '<tableStyleInfo name="TableStyleMedium9" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/>'
|
8
13
|
|
9
|
-
table = Writexlsx::Package::Table.new
|
10
|
-
table.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:_show_row_stripes => 1,
|
17
|
-
:_show_col_stripes => 0
|
18
|
-
}
|
19
|
-
)
|
14
|
+
table = Writexlsx::Package::Table.new(@worksheet, 0, 1, 1, 2, 2)
|
15
|
+
table.instance_variable_set(:@style, 'TableStyleMedium9')
|
16
|
+
table.instance_variable_set(:@show_first_col, 0)
|
17
|
+
table.instance_variable_set(:@show_last_col, 0)
|
18
|
+
table.instance_variable_set(:@show_row_stripes, 1)
|
19
|
+
table.instance_variable_set(:@show_col_stripes, 0)
|
20
|
+
|
20
21
|
table.__send__(:write_table_style_info)
|
21
22
|
result = table.instance_variable_get(:@writer).string
|
22
23
|
|
@@ -3,10 +3,15 @@ require 'helper'
|
|
3
3
|
require 'write_xlsx/package/table'
|
4
4
|
|
5
5
|
class TestTableWriteXmlDeclaration < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
workbook = WriteXLSX.new(StringIO.new)
|
8
|
+
@worksheet = workbook.add_worksheet
|
9
|
+
end
|
10
|
+
|
6
11
|
def test_table_write_xml_declaration
|
7
12
|
expected = %Q{<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n}
|
8
13
|
|
9
|
-
table = Writexlsx::Package::Table.new
|
14
|
+
table = Writexlsx::Package::Table.new(@worksheet, 0, 1, 1, 2, 2)
|
10
15
|
table.__send__(:write_xml_declaration)
|
11
16
|
result = table.instance_variable_get(:@writer).string
|
12
17
|
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionMacro01 < 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_macro01
|
14
|
+
@xlsx = 'macro01.xlsm'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
|
18
|
+
workbook.add_vba_project(File.join(
|
19
|
+
@regression_output,
|
20
|
+
'vbaProject01.bin'
|
21
|
+
)
|
22
|
+
)
|
23
|
+
|
24
|
+
worksheet.write('A1', 123)
|
25
|
+
|
26
|
+
workbook.close
|
27
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
28
|
+
end
|
29
|
+
end
|
Binary file
|
Binary file
|
data/test/test_example_match.rb
CHANGED
@@ -4837,4 +4837,26 @@ EOS
|
|
4837
4837
|
workbook.close
|
4838
4838
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
4839
4839
|
end
|
4840
|
+
|
4841
|
+
def test_add_vba_project
|
4842
|
+
@xlsx = 'add_vba_project.xlsm'
|
4843
|
+
workbook = WriteXLSX.new(@xlsx)
|
4844
|
+
worksheet = workbook.add_worksheet
|
4845
|
+
|
4846
|
+
worksheet.set_column('A:A', 50)
|
4847
|
+
|
4848
|
+
# Add the VBA project binary.
|
4849
|
+
workbook.add_vba_project(File.join(@test_dir, 'vbaProject.bin'))
|
4850
|
+
|
4851
|
+
# Show text for the end user.
|
4852
|
+
worksheet.write('A1', 'Run the SampleMacro embedded in this file.')
|
4853
|
+
worksheet.write('A2', 'You may have to turn on the Excel Developer option first.')
|
4854
|
+
|
4855
|
+
# Call a user defined function from the VBA project.
|
4856
|
+
worksheet.write('A6', 'Result from a user defined function:')
|
4857
|
+
worksheet.write('B6', '=MyFunction(7)')
|
4858
|
+
|
4859
|
+
workbook.close
|
4860
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
4861
|
+
end
|
4840
4862
|
end
|
data/test/vbaProject.bin
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: write_xlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.59.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
@@ -39,7 +39,8 @@ description: ! "write_xlsx s a gem to create a new file in the Excel 2007+ XLSX
|
|
39
39
|
in this gem.\n"
|
40
40
|
email:
|
41
41
|
- cxn03651@msj.biglobe.ne.jp
|
42
|
-
executables:
|
42
|
+
executables:
|
43
|
+
- extract_vba.rb
|
43
44
|
extensions: []
|
44
45
|
extra_rdoc_files:
|
45
46
|
- LICENSE.txt
|
@@ -52,7 +53,9 @@ files:
|
|
52
53
|
- LICENSE.txt
|
53
54
|
- README.rdoc
|
54
55
|
- Rakefile
|
56
|
+
- bin/extract_vba.rb
|
55
57
|
- examples/a_simple.rb
|
58
|
+
- examples/add_vba_project.rb
|
56
59
|
- examples/array_formula.rb
|
57
60
|
- examples/autofilter.rb
|
58
61
|
- examples/chart_area.rb
|
@@ -107,6 +110,7 @@ files:
|
|
107
110
|
- examples/stocks.rb
|
108
111
|
- examples/tab_colors.rb
|
109
112
|
- examples/tables.rb
|
113
|
+
- examples/vbaProject.bin
|
110
114
|
- lib/write_xlsx.rb
|
111
115
|
- lib/write_xlsx/chart.rb
|
112
116
|
- lib/write_xlsx/chart/area.rb
|
@@ -124,6 +128,7 @@ files:
|
|
124
128
|
- lib/write_xlsx/format.rb
|
125
129
|
- lib/write_xlsx/package/app.rb
|
126
130
|
- lib/write_xlsx/package/comments.rb
|
131
|
+
- lib/write_xlsx/package/conditional_format.rb
|
127
132
|
- lib/write_xlsx/package/content_types.rb
|
128
133
|
- lib/write_xlsx/package/core.rb
|
129
134
|
- lib/write_xlsx/package/packager.rb
|
@@ -254,6 +259,7 @@ files:
|
|
254
259
|
- test/package/vml/test_write_stroke.rb
|
255
260
|
- test/package/vml/test_write_textbox.rb
|
256
261
|
- test/perl_output/a_simple.xlsx
|
262
|
+
- test/perl_output/add_vba_project.xlsm
|
257
263
|
- test/perl_output/array_formula.xlsx
|
258
264
|
- test/perl_output/autofilter.xlsx
|
259
265
|
- test/perl_output/chart_area.xlsx
|
@@ -533,6 +539,7 @@ files:
|
|
533
539
|
- test/regression/test_image05.rb
|
534
540
|
- test/regression/test_image06.rb
|
535
541
|
- test/regression/test_image07.rb
|
542
|
+
- test/regression/test_macro01.rb
|
536
543
|
- test/regression/test_outline01.rb
|
537
544
|
- test/regression/test_outline02.rb
|
538
545
|
- test/regression/test_outline03.rb
|
@@ -833,6 +840,7 @@ files:
|
|
833
840
|
- test/regression/xlsx_files/image05.xlsx
|
834
841
|
- test/regression/xlsx_files/image06.xlsx
|
835
842
|
- test/regression/xlsx_files/image07.xlsx
|
843
|
+
- test/regression/xlsx_files/macro01.xlsm
|
836
844
|
- test/regression/xlsx_files/outline01.xlsx
|
837
845
|
- test/regression/xlsx_files/outline02.xlsx
|
838
846
|
- test/regression/xlsx_files/outline03.xlsx
|
@@ -919,9 +927,11 @@ files:
|
|
919
927
|
- test/regression/xlsx_files/table12.xlsx
|
920
928
|
- test/regression/xlsx_files/table13.xlsx
|
921
929
|
- test/regression/xlsx_files/table14.xlsx
|
930
|
+
- test/regression/xlsx_files/vbaProject01.bin
|
922
931
|
- test/test_delete_files.rb
|
923
932
|
- test/test_example_match.rb
|
924
933
|
- test/test_xml_writer_simple.rb
|
934
|
+
- test/vbaProject.bin
|
925
935
|
- test/workbook/test_get_chart_range.rb
|
926
936
|
- test/workbook/test_sort_defined_names.rb
|
927
937
|
- test/workbook/test_workbook_01.rb
|
@@ -1162,6 +1172,7 @@ test_files:
|
|
1162
1172
|
- test/package/vml/test_write_stroke.rb
|
1163
1173
|
- test/package/vml/test_write_textbox.rb
|
1164
1174
|
- test/perl_output/a_simple.xlsx
|
1175
|
+
- test/perl_output/add_vba_project.xlsm
|
1165
1176
|
- test/perl_output/array_formula.xlsx
|
1166
1177
|
- test/perl_output/autofilter.xlsx
|
1167
1178
|
- test/perl_output/chart_area.xlsx
|
@@ -1441,6 +1452,7 @@ test_files:
|
|
1441
1452
|
- test/regression/test_image05.rb
|
1442
1453
|
- test/regression/test_image06.rb
|
1443
1454
|
- test/regression/test_image07.rb
|
1455
|
+
- test/regression/test_macro01.rb
|
1444
1456
|
- test/regression/test_outline01.rb
|
1445
1457
|
- test/regression/test_outline02.rb
|
1446
1458
|
- test/regression/test_outline03.rb
|
@@ -1741,6 +1753,7 @@ test_files:
|
|
1741
1753
|
- test/regression/xlsx_files/image05.xlsx
|
1742
1754
|
- test/regression/xlsx_files/image06.xlsx
|
1743
1755
|
- test/regression/xlsx_files/image07.xlsx
|
1756
|
+
- test/regression/xlsx_files/macro01.xlsm
|
1744
1757
|
- test/regression/xlsx_files/outline01.xlsx
|
1745
1758
|
- test/regression/xlsx_files/outline02.xlsx
|
1746
1759
|
- test/regression/xlsx_files/outline03.xlsx
|
@@ -1827,9 +1840,11 @@ test_files:
|
|
1827
1840
|
- test/regression/xlsx_files/table12.xlsx
|
1828
1841
|
- test/regression/xlsx_files/table13.xlsx
|
1829
1842
|
- test/regression/xlsx_files/table14.xlsx
|
1843
|
+
- test/regression/xlsx_files/vbaProject01.bin
|
1830
1844
|
- test/test_delete_files.rb
|
1831
1845
|
- test/test_example_match.rb
|
1832
1846
|
- test/test_xml_writer_simple.rb
|
1847
|
+
- test/vbaProject.bin
|
1833
1848
|
- test/workbook/test_get_chart_range.rb
|
1834
1849
|
- test/workbook/test_sort_defined_names.rb
|
1835
1850
|
- test/workbook/test_workbook_01.rb
|