write_xlsx 0.0.3 → 0.0.4
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.
- data/README.rdoc +3 -0
- data/VERSION +1 -1
- data/lib/write_xlsx/chart.rb +421 -604
- data/lib/write_xlsx/chart/area.rb +6 -9
- data/lib/write_xlsx/chart/bar.rb +1 -44
- data/lib/write_xlsx/chart/column.rb +1 -46
- data/lib/write_xlsx/chart/line.rb +6 -9
- data/lib/write_xlsx/chart/pie.rb +42 -63
- data/lib/write_xlsx/chart/scatter.rb +42 -96
- data/lib/write_xlsx/chart/stock.rb +14 -21
- data/lib/write_xlsx/chartsheet.rb +4 -4
- data/lib/write_xlsx/drawing.rb +112 -163
- data/lib/write_xlsx/format.rb +62 -47
- data/lib/write_xlsx/package/app.rb +14 -19
- data/lib/write_xlsx/package/comments.rb +37 -48
- data/lib/write_xlsx/package/core.rb +12 -34
- data/lib/write_xlsx/package/packager.rb +10 -15
- data/lib/write_xlsx/package/relationships.rb +3 -5
- data/lib/write_xlsx/package/shared_strings.rb +7 -9
- data/lib/write_xlsx/package/styles.rb +148 -172
- data/lib/write_xlsx/package/vml.rb +43 -65
- data/lib/write_xlsx/package/xml_writer_simple.rb +7 -3
- data/lib/write_xlsx/workbook.rb +30 -67
- data/lib/write_xlsx/worksheet.rb +189 -239
- data/test/chart/test_write_format_code.rb +2 -1
- data/test/helper.rb +9 -0
- data/test/perl_output/chart_scatter06.xlsx +0 -0
- data/test/test_example_match.rb +37 -0
- data/test/test_xml_writer_simple.rb +9 -8
- data/test/worksheet/test_write_cell.rb +10 -10
- data/write_xlsx.gemspec +3 -2
- metadata +12 -11
@@ -9,7 +9,8 @@ def setup
|
|
9
9
|
|
10
10
|
def test_write_format_code
|
11
11
|
expected = '<c:formatCode>General</c:formatCode>'
|
12
|
-
|
12
|
+
@chart.__send__('write_format_code', 'General')
|
13
|
+
result = @chart.instance_variable_get(:@writer).string
|
13
14
|
assert_equal(expected, result)
|
14
15
|
end
|
15
16
|
end
|
data/test/helper.rb
CHANGED
@@ -14,6 +14,15 @@
|
|
14
14
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
15
|
require 'write_xlsx'
|
16
16
|
|
17
|
+
class Writexlsx::Workbook
|
18
|
+
#
|
19
|
+
# Set the default index for each format. This is mainly used for testing.
|
20
|
+
#
|
21
|
+
def set_default_xf_indices #:nodoc:
|
22
|
+
@formats.each { |format| format.get_xf_index }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
17
26
|
class Test::Unit::TestCase
|
18
27
|
def setup_dir_var
|
19
28
|
@test_dir = File.dirname(__FILE__)
|
Binary file
|
data/test/test_example_match.rb
CHANGED
@@ -2705,6 +2705,43 @@ def test_autofilter
|
|
2705
2705
|
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
2706
2706
|
end
|
2707
2707
|
|
2708
|
+
def test_chart_scatter06
|
2709
|
+
xlsx = 'chart_scatter06.xlsx'
|
2710
|
+
workbook = WriteXLSX.new(xlsx)
|
2711
|
+
worksheet = workbook.add_worksheet
|
2712
|
+
chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
|
2713
|
+
|
2714
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
2715
|
+
chart.instance_variable_set(:@axis_ids, [57708544, 44297600])
|
2716
|
+
|
2717
|
+
data = [
|
2718
|
+
[ 1, 2, 3, 4, 5 ],
|
2719
|
+
[ 2, 4, 6, 8, 10 ],
|
2720
|
+
[ 3, 6, 9, 12, 15 ],
|
2721
|
+
|
2722
|
+
]
|
2723
|
+
|
2724
|
+
worksheet.write('A1', data)
|
2725
|
+
|
2726
|
+
chart.add_series(
|
2727
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
2728
|
+
:values => '=Sheet1!$B$1:$B$5',
|
2729
|
+
)
|
2730
|
+
|
2731
|
+
chart.add_series(
|
2732
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
2733
|
+
:values => '=Sheet1!$C$1:$C$5',
|
2734
|
+
)
|
2735
|
+
|
2736
|
+
chart.set_x_axis(:minor_unit => 1, :major_unit => 3)
|
2737
|
+
chart.set_y_axis(:minor_unit => 2, :major_unit => 4)
|
2738
|
+
|
2739
|
+
worksheet.insert_chart('E9', chart)
|
2740
|
+
|
2741
|
+
workbook.close
|
2742
|
+
compare_xlsx(@expected_dir, @result_dir, xlsx)
|
2743
|
+
end
|
2744
|
+
|
2708
2745
|
def autofilter_data
|
2709
2746
|
<<EOS
|
2710
2747
|
Region Item Volume Month
|
@@ -44,10 +44,10 @@ def test_character_data
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_data_element_with_empty_attr
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
)
|
47
|
+
expected = "<foo>data</foo>"
|
48
|
+
@obj.data_element('foo', 'data')
|
49
|
+
result = @obj.string
|
50
|
+
assert_equal(expected, result)
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_data_element
|
@@ -55,9 +55,10 @@ def test_data_element
|
|
55
55
|
'name', '_xlnm.Print_Titles',
|
56
56
|
'localSheetId', 0
|
57
57
|
]
|
58
|
-
|
59
|
-
"<definedName name=\"_xlnm.Print_Titles\" localSheetId=\"0\">Sheet1!$1:$1</definedName>"
|
60
|
-
|
61
|
-
|
58
|
+
expected =
|
59
|
+
"<definedName name=\"_xlnm.Print_Titles\" localSheetId=\"0\">Sheet1!$1:$1</definedName>"
|
60
|
+
@obj.data_element('definedName', 'Sheet1!$1:$1', attributes)
|
61
|
+
result = @obj.string
|
62
|
+
assert_equal(expected, result)
|
62
63
|
end
|
63
64
|
end
|
@@ -10,16 +10,16 @@ def setup
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_write_cell_0_0_n_1
|
13
|
-
cell_data = Writexlsx::Worksheet::NumberCellData.new(0, 0, 1, nil)
|
14
|
-
cell_data.write_cell
|
13
|
+
cell_data = Writexlsx::Worksheet::NumberCellData.new(@worksheet, 0, 0, 1, nil)
|
14
|
+
cell_data.write_cell
|
15
15
|
result = @worksheet.instance_variable_get(:@writer).string
|
16
16
|
expected = '<c r="A1"><v>1</v></c>'
|
17
17
|
assert_equal(expected, result)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_write_cell_3_1_s_0
|
21
|
-
cell_data = Writexlsx::Worksheet::StringCellData.new(3, 1, 0, nil)
|
22
|
-
cell_data.write_cell
|
21
|
+
cell_data = Writexlsx::Worksheet::StringCellData.new(@worksheet, 3, 1, 0, nil)
|
22
|
+
cell_data.write_cell
|
23
23
|
result = @worksheet.instance_variable_get(:@writer).string
|
24
24
|
expected = '<c r="B4" t="s"><v>0</v></c>'
|
25
25
|
assert_equal(expected, result)
|
@@ -27,8 +27,8 @@ def test_write_cell_3_1_s_0
|
|
27
27
|
|
28
28
|
def test_write_cell_1_2_f_formula_nil_0
|
29
29
|
format = nil
|
30
|
-
cell_data = Writexlsx::Worksheet::FormulaCellData.new(1, 2, 'A3+A5', format, 0)
|
31
|
-
cell_data.write_cell
|
30
|
+
cell_data = Writexlsx::Worksheet::FormulaCellData.new(@worksheet, 1, 2, 'A3+A5', format, 0)
|
31
|
+
cell_data.write_cell
|
32
32
|
result = @worksheet.instance_variable_get(:@writer).string
|
33
33
|
expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>'
|
34
34
|
assert_equal(expected, result)
|
@@ -36,8 +36,8 @@ def test_write_cell_1_2_f_formula_nil_0
|
|
36
36
|
|
37
37
|
def test_write_cell_1_2_f_formula
|
38
38
|
format = nil
|
39
|
-
cell_data = Writexlsx::Worksheet::FormulaCellData.new(1, 2, 'A3+A5', nil, nil)
|
40
|
-
cell_data.write_cell
|
39
|
+
cell_data = Writexlsx::Worksheet::FormulaCellData.new(@worksheet, 1, 2, 'A3+A5', nil, nil)
|
40
|
+
cell_data.write_cell
|
41
41
|
result = @worksheet.instance_variable_get(:@writer).string
|
42
42
|
expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>'
|
43
43
|
assert_equal(expected, result)
|
@@ -45,8 +45,8 @@ def test_write_cell_1_2_f_formula
|
|
45
45
|
|
46
46
|
def test_write_cell_0_0_a_formula_nil_a1_9500
|
47
47
|
format = nil
|
48
|
-
cell_data = Writexlsx::Worksheet::FormulaArrayCellData.new(0, 0, 'SUM(B1:C1*B2:C2)', format, 'A1', 9500)
|
49
|
-
cell_data.write_cell
|
48
|
+
cell_data = Writexlsx::Worksheet::FormulaArrayCellData.new(@worksheet, 0, 0, 'SUM(B1:C1*B2:C2)', format, 'A1', 9500)
|
49
|
+
cell_data.write_cell
|
50
50
|
result = @worksheet.instance_variable_get(:@writer).string
|
51
51
|
expected = '<c r="A1"><f t="array" ref="A1">SUM(B1:C1*B2:C2)</f><v>9500</v></c>'
|
52
52
|
assert_equal(expected, result)
|
data/write_xlsx.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "write_xlsx"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hideo NAKAMURA"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-02-13"
|
13
13
|
s.description = "write_xlsx s a gem to create a new file in the Excel 2007+ XLSX format, and you can use the same interface as writeexcel gem.\nThe WriteXLSX supports the following features:\n * Multiple worksheets\n * Strings and numbers\n * Unicode text\n * Rich string formats\n * Formulas (including array formats)\n * cell formatting\n * Embedded images\n * Charts\n * Autofilters\n * Data validation\n * Hyperlinks\n * Defined names\n * Grouping/Outlines\n * Cell comments\n * Panes\n * Page set-up and printing options\n\nwrite_xlsx uses the same interface as writeexcel gem.\n\ndocumentation is not completed, but writeexcel\u{2019}s documentation will help you. See http://writeexcel.web.fc2.com/\n\nAnd you can find many examples in this gem.\n"
|
14
14
|
s.email = "cxn03651@msj.biglobe.ne.jp"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -174,6 +174,7 @@ Gem::Specification.new do |s|
|
|
174
174
|
"test/perl_output/chart_line.xlsx",
|
175
175
|
"test/perl_output/chart_pie.xlsx",
|
176
176
|
"test/perl_output/chart_scatter.xlsx",
|
177
|
+
"test/perl_output/chart_scatter06.xlsx",
|
177
178
|
"test/perl_output/chart_stock.xlsx",
|
178
179
|
"test/perl_output/comments1.xlsx",
|
179
180
|
"test/perl_output/comments2.xlsx",
|
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.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
16
|
-
requirement: &
|
16
|
+
requirement: &71968630 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *71968630
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &71967640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *71967640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &71967360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *71967360
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &71967110 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *71967110
|
58
58
|
description: ! "write_xlsx s a gem to create a new file in the Excel 2007+ XLSX format,
|
59
59
|
and you can use the same interface as writeexcel gem.\nThe WriteXLSX supports the
|
60
60
|
following features:\n * Multiple worksheets\n * Strings and numbers\n * Unicode
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- test/perl_output/chart_line.xlsx
|
230
230
|
- test/perl_output/chart_pie.xlsx
|
231
231
|
- test/perl_output/chart_scatter.xlsx
|
232
|
+
- test/perl_output/chart_scatter06.xlsx
|
232
233
|
- test/perl_output/chart_stock.xlsx
|
233
234
|
- test/perl_output/comments1.xlsx
|
234
235
|
- test/perl_output/comments2.xlsx
|
@@ -347,7 +348,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
348
|
version: '0'
|
348
349
|
segments:
|
349
350
|
- 0
|
350
|
-
hash:
|
351
|
+
hash: 986643521
|
351
352
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
353
|
none: false
|
353
354
|
requirements:
|