xlsxwriter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +40 -0
- data/ext/xlsxwriter/chart.c +105 -0
- data/ext/xlsxwriter/chart.h +27 -0
- data/ext/xlsxwriter/extconf.rb +14 -0
- data/ext/xlsxwriter/format.c +67 -0
- data/ext/xlsxwriter/format.h +9 -0
- data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
- data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
- data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
- data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
- data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/workbook.c +257 -0
- data/ext/xlsxwriter/workbook.h +42 -0
- data/ext/xlsxwriter/workbook_properties.c +103 -0
- data/ext/xlsxwriter/workbook_properties.h +10 -0
- data/ext/xlsxwriter/worksheet.c +1064 -0
- data/ext/xlsxwriter/worksheet.h +74 -0
- data/ext/xlsxwriter/xlsxwriter.c +239 -0
- data/lib/xlsxwriter.rb +6 -0
- data/lib/xlsxwriter/version.rb +3 -0
- data/lib/xlsxwriter/worksheet.rb +72 -0
- data/test/run-test.rb +11 -0
- data/test/support/xlsx_comparable.rb +109 -0
- data/test/test-array-formula.rb +33 -0
- data/test/test-autofilter.rb +70 -0
- data/test/test-chart-area.rb +25 -0
- data/test/test-data.rb +65 -0
- data/test/test-default-row.rb +25 -0
- data/test/test-defined-name.rb +46 -0
- data/test/test-escapes.rb +33 -0
- data/test/test-fit-to-pages.rb +21 -0
- data/test/test-formatting.rb +137 -0
- data/test/test-gridlines.rb +15 -0
- data/test/test-hyperlink.rb +67 -0
- data/test/test-image.rb +84 -0
- data/test/test-merge-range.rb +18 -0
- data/test/test-misc.rb +29 -0
- data/test/test-optimize.rb +32 -0
- data/test/test-page-breaks.rb +13 -0
- data/test/test-page-setup.rb +28 -0
- data/test/test-panes.rb +45 -0
- data/test/test-print-area.rb +19 -0
- data/test/test-print-options.rb +61 -0
- data/test/test-print-scale.rb +12 -0
- data/test/test-properties.rb +51 -0
- data/test/test-protect.rb +27 -0
- data/test/test-repeat.rb +23 -0
- data/test/test-row-col-format.rb +35 -0
- data/test/test-set-selection.rb +13 -0
- data/test/test-set-start-page.rb +13 -0
- data/test/test-simple.rb +62 -0
- data/test/test-types.rb +17 -0
- data/test/xlsx-func-testcase.rb +36 -0
- metadata +228 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestArrayFormula < XlsxWriterTestCase
|
4
|
+
def setup
|
5
|
+
omit 'runs wrong test in libxlsxwriter'
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'array_formula01' do |wb|
|
9
|
+
ws = wb.add_worksheet nil
|
10
|
+
ws.write_number(0, 1, 0, nil)
|
11
|
+
ws.write_number(1, 1, 0, nil)
|
12
|
+
ws.write_number(2, 1, 0, nil)
|
13
|
+
ws.write_number(0, 2, 0, nil)
|
14
|
+
ws.write_number(1, 2, 0, nil)
|
15
|
+
ws.write_number(2, 2, 0, nil)
|
16
|
+
|
17
|
+
ws.write_array_formula(0, 0, 2, 0, '{=SUM(B1:C1*B2:C2)}', nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'array_formula02' do |wb|
|
21
|
+
ws = wb.add_worksheet
|
22
|
+
wb.add_format(:bold, bold: true)
|
23
|
+
|
24
|
+
ws.write_number(0, 1, 0, nil);
|
25
|
+
ws.write_number(1, 1, 0, nil);
|
26
|
+
ws.write_number(2, 1, 0, nil);
|
27
|
+
ws.write_number(0, 2, 0, nil);
|
28
|
+
ws.write_number(1, 2, 0, nil);
|
29
|
+
ws.write_number(2, 2, 0, nil);
|
30
|
+
|
31
|
+
ws.write_array_formula(0, 0, 2, 0, '{=SUM(B1:C1*B2:C2)}', :bold)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestAutofilter < XlsxWriterTestCase
|
4
|
+
ROWS = [
|
5
|
+
%w(Region Item Volume Month),
|
6
|
+
[ 'East', 'Apple', 9000, 'July' ],
|
7
|
+
[ 'East', 'Apple', 5000, 'July' ],
|
8
|
+
[ 'South', 'Orange', 9000, 'September' ],
|
9
|
+
[ 'North', 'Apple', 2000, 'November' ],
|
10
|
+
[ 'West', 'Apple', 9000, 'November' ],
|
11
|
+
[ 'South', 'Pear', 7000, 'October' ],
|
12
|
+
[ 'North', 'Pear', 9000, 'August' ],
|
13
|
+
[ 'West', 'Orange', 1000, 'December' ],
|
14
|
+
[ 'West', 'Grape', 1000, 'November' ],
|
15
|
+
[ 'South', 'Pear', 10000, 'April' ],
|
16
|
+
[ 'West', 'Grape', 6000, 'January' ],
|
17
|
+
[ 'South', 'Orange', 3000, 'May' ],
|
18
|
+
[ 'North', 'Apple', 3000, 'December' ],
|
19
|
+
[ 'South', 'Apple', 7000, 'February' ],
|
20
|
+
[ 'West', 'Grape', 1000, 'December' ],
|
21
|
+
[ 'East', 'Grape', 8000, 'February' ],
|
22
|
+
[ 'South', 'Grape', 10000, 'June' ],
|
23
|
+
[ 'West', 'Pear', 7000, 'December' ],
|
24
|
+
[ 'South', 'Apple', 2000, 'October' ],
|
25
|
+
[ 'East', 'Grape', 7000, 'December' ],
|
26
|
+
[ 'North', 'Grape', 6000, 'April' ],
|
27
|
+
[ 'East', 'Pear', 8000, 'February' ],
|
28
|
+
[ 'North', 'Apple', 7000, 'August' ],
|
29
|
+
[ 'North', 'Orange', 7000, 'July' ],
|
30
|
+
[ 'North', 'Apple', 6000, 'June' ],
|
31
|
+
[ 'South', 'Grape', 8000, 'September' ],
|
32
|
+
[ 'West', 'Apple', 3000, 'October' ],
|
33
|
+
[ 'South', 'Orange', 10000, 'November' ],
|
34
|
+
[ 'West', 'Grape', 4000, 'July' ],
|
35
|
+
[ 'North', 'Orange', 5000, 'August' ],
|
36
|
+
[ 'East', 'Orange', 1000, 'November' ],
|
37
|
+
[ 'East', 'Orange', 4000, 'October' ],
|
38
|
+
[ 'North', 'Grape', 5000, 'August' ],
|
39
|
+
[ 'East', 'Apple', 1000, 'December' ],
|
40
|
+
[ 'South', 'Apple', 10000, 'March' ],
|
41
|
+
[ 'East', 'Grape', 7000, 'October' ],
|
42
|
+
[ 'West', 'Grape', 1000, 'September' ],
|
43
|
+
[ 'East', 'Grape', 10000, 'October' ],
|
44
|
+
[ 'South', 'Orange', 8000, 'March' ],
|
45
|
+
[ 'North', 'Apple', 4000, 'July' ],
|
46
|
+
[ 'South', 'Orange', 5000, 'July' ],
|
47
|
+
[ 'West', 'Apple', 4000, 'June' ],
|
48
|
+
[ 'East', 'Apple', 5000, 'April' ],
|
49
|
+
[ 'North', 'Pear', 3000, 'August' ],
|
50
|
+
[ 'East', 'Grape', 9000, 'November' ],
|
51
|
+
[ 'North', 'Orange', 8000, 'October' ],
|
52
|
+
[ 'East', 'Apple', 10000, 'June' ],
|
53
|
+
[ 'South', 'Pear', 1000, 'December' ],
|
54
|
+
[ 'North', 'Grape', 10000, 'July' ],
|
55
|
+
[ 'East', 'Grape', 6000, 'February' ]
|
56
|
+
]
|
57
|
+
|
58
|
+
test 'autofilter00' do |wb|
|
59
|
+
ws = wb.add_worksheet
|
60
|
+
|
61
|
+
ROWS.each { |row| ws.add_row row }
|
62
|
+
end
|
63
|
+
|
64
|
+
test 'autofilter01' do |wb|
|
65
|
+
ws = wb.add_worksheet
|
66
|
+
|
67
|
+
ROWS.each { |row| ws.add_row row }
|
68
|
+
ws.autofilter('A1', 50, 3);
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestChartArea < XlsxWriterTestCase
|
4
|
+
test 'chart_area03' do |wb|
|
5
|
+
wb.add_worksheet do |ws|
|
6
|
+
[
|
7
|
+
[1, 8, 3],
|
8
|
+
[2, 7, 6],
|
9
|
+
[3, 6, 9],
|
10
|
+
[4, 8, 12],
|
11
|
+
[5, 10, 15]
|
12
|
+
].each { |row| ws.add_row row }
|
13
|
+
|
14
|
+
wb.add_chart(XlsxWriter::Workbook::Chart::AREA_STACKED_PERCENT) do |chart|
|
15
|
+
chart.axis_id_1 = 62_813_312
|
16
|
+
chart.axis_id_2 = 62_814_848
|
17
|
+
|
18
|
+
chart.add_series '=Sheet1!$A$1:$A$5', '=Sheet1!$B$1:$B$5'
|
19
|
+
chart.add_series '=Sheet1!$A$1:$A$5', '=Sheet1!$C$1:$C$5'
|
20
|
+
|
21
|
+
ws.insert_chart 'E9', chart
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test-data.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestData < XlsxWriterTestCase
|
4
|
+
test 'data01' do |wb|
|
5
|
+
ws = wb.add_worksheet
|
6
|
+
ws.write_string(0, 0, 'Hello', nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'data02' do |wb|
|
10
|
+
ws = wb.add_worksheet
|
11
|
+
|
12
|
+
# in range
|
13
|
+
ws.write_number(0, 0, 123, nil)
|
14
|
+
ws.write_number(1_048_575, 0, 456, nil)
|
15
|
+
|
16
|
+
# out of range
|
17
|
+
ws.write_number(-1, 0, 123, nil)
|
18
|
+
ws.write_number(1_048_576, 0, 456, nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'data03' do |wb|
|
22
|
+
ws = wb.add_worksheet
|
23
|
+
|
24
|
+
ws.write_number(0, 16_383, 123, nil)
|
25
|
+
ws.write_number(1_048_575, 16_383, 456, nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'data04' do |wb|
|
29
|
+
ws = wb.add_worksheet
|
30
|
+
|
31
|
+
ws.write_string(0, 0, 'Foo', nil)
|
32
|
+
ws.write_string(0, 1, 'Bar', nil)
|
33
|
+
ws.write_string(1, 0, 'Bing', nil)
|
34
|
+
ws.write_string(2, 0, 'Buzz', nil)
|
35
|
+
ws.write_string(1_048_575, 0, 'End', nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'data05' do |wb|
|
39
|
+
ws = wb.add_worksheet
|
40
|
+
|
41
|
+
wb.add_format :format, bold: 1
|
42
|
+
ws.write_string 0, 0, 'Foo', :format
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'data06' do |wb|
|
46
|
+
ws = wb.add_worksheet
|
47
|
+
|
48
|
+
wb.add_format :f1, bold: true
|
49
|
+
wb.add_format :f2, italic: true
|
50
|
+
wb.add_format :f3, bold: true, italic: true
|
51
|
+
|
52
|
+
ws.write_string 0, 'A', 'Foo', :f1
|
53
|
+
ws.write_string 1, 'A', 'Bar', :f2
|
54
|
+
ws.write_string 2, 'A', 'Baz', :f3
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'data07' do |wb, t|
|
58
|
+
t.ignore_files = ['xl/calcChain.xml',
|
59
|
+
'[Content_Types].xml',
|
60
|
+
'xl/_rels/workbook.xml.rels']
|
61
|
+
ws = wb.add_worksheet
|
62
|
+
|
63
|
+
ws.write_formula_num 'A1', '=1+2', 3
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestDefaultRow < XlsxWriterTestCase
|
4
|
+
test 'default_row01' do |wb|
|
5
|
+
ws = wb.add_worksheet
|
6
|
+
|
7
|
+
ws.set_default_row(24, false)
|
8
|
+
|
9
|
+
ws.write_string(0, 'A', 'Foo', nil)
|
10
|
+
ws.write_string(9, 'A', 'Bar', nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'default_row05' do |wb|
|
14
|
+
ws = wb.add_worksheet
|
15
|
+
|
16
|
+
ws.set_default_row(24, true)
|
17
|
+
|
18
|
+
ws.write_string(0, 'A', 'Foo', nil)
|
19
|
+
ws.write_string(9, 'A', 'Bar', nil)
|
20
|
+
ws.write_string(19, 'A', 'Baz', nil)
|
21
|
+
|
22
|
+
(1..8).each { |i| ws.set_row(i, height: 24) }
|
23
|
+
(10..19).each { |i| ws.set_row(i, height: 24) }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestDefinedName < XlsxWriterTestCase
|
4
|
+
test 'defined_name01' do |wb, t|
|
5
|
+
t.ignore_elements = { 'xl/worksheets/sheet1.xml' => [ '<pageMargins' ] }
|
6
|
+
wb.add_worksheet do |ws|
|
7
|
+
ws.paper = 9
|
8
|
+
ws.vertical_dpi = 200
|
9
|
+
ws
|
10
|
+
.print_area(0, 'A', 5, 'E')
|
11
|
+
.autofilter(0, 'F', 0, 'G')
|
12
|
+
.write_string(0, 'G', 'Filter')
|
13
|
+
.write_string(0, 'F', 'Auto')
|
14
|
+
.fit_to_pages(2, 2)
|
15
|
+
end
|
16
|
+
|
17
|
+
wb.add_worksheet
|
18
|
+
wb.add_worksheet 'Sheet 3'
|
19
|
+
|
20
|
+
wb.define_name "'Sheet 3'!Bar", "='Sheet 3'!$A$1"
|
21
|
+
wb.define_name "Abc", "=Sheet1!$A$1"
|
22
|
+
wb.define_name "Baz", "=0.98"
|
23
|
+
wb.define_name "Sheet1!Bar", "=Sheet1!$A$1"
|
24
|
+
wb.define_name "Sheet2!Bar", "=Sheet2!$A$1"
|
25
|
+
wb.define_name "Sheet2!aaa", "=Sheet2!$A$1"
|
26
|
+
wb.define_name "_Egg", "=Sheet1!$A$1"
|
27
|
+
wb.define_name "_Fog", "=Sheet1!$A$1"
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'defined_name03' do |wb, t|
|
31
|
+
t.ignore_elements = { 'xl/worksheets/sheet1.xml' => [ '<pageMargins' ] }
|
32
|
+
wb.add_worksheet('sheet One')
|
33
|
+
wb.define_name 'Sales', '=\'sheet One\'!G1:H10'
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'defined_name04' do |wb, t|
|
37
|
+
t.ignore_elements = { 'xl/worksheets/sheet1.xml' => [ '<pageMargins' ] }
|
38
|
+
wb.add_worksheet
|
39
|
+
wb.define_name '\\__', '=Sheet1!$A$1'
|
40
|
+
wb.define_name 'a3f6', '=Sheet1!$A$2'
|
41
|
+
wb.define_name 'afoo.bar', '=Sheet1!$A$3'
|
42
|
+
wb.define_name "\xc3\xa9tude", '=Sheet1!$A$4'
|
43
|
+
wb.define_name "e\xc3\xa9sum\xc3\xa9", '=Sheet1!$A$5'
|
44
|
+
wb.define_name 'a', '=Sheet1!$A$6'
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestEscapes < XlsxWriterTestCase
|
4
|
+
test 'escapes04' do |wb|
|
5
|
+
wb.add_worksheet
|
6
|
+
.write_url(0, 'A', 'http://www.perl.com/?a=1&b=2')
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'escapes05' do |wb|
|
10
|
+
wb.add_worksheet('Start')
|
11
|
+
.write_url(0, 'A', 'internal:\'A & B\'!A1', string: 'Jump to A & B')
|
12
|
+
wb.add_worksheet('A & B')
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'escapes06' do |wb|
|
16
|
+
ws = wb.add_worksheet
|
17
|
+
ws.set_column(0, 0, width: 14)
|
18
|
+
wb.add_format :f1, num_format: '[Red]0.0%\\ "a"'
|
19
|
+
ws.write_number(0, 'A', 123, :f1)
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'escapes07' do |wb|
|
23
|
+
wb.add_worksheet
|
24
|
+
.write_url(0, 'A', 'http://example.com/!"$%&\'( )*+,-./0123456789:;<=>?@' \
|
25
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' \
|
26
|
+
'abcdefghijklmnopqrstuvwxyz{|}~', nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'escapes08' do |wb|
|
30
|
+
wb.add_worksheet
|
31
|
+
.write_url 0, 'A', 'http://example.com/%5b0%5d', string: 'http://example.com/[0]'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestFitToPages < XlsxWriterTestCase
|
4
|
+
test 'fit_to_pages04' do |wb, t|
|
5
|
+
t.ignore_elements = { 'xl/worksheets/sheet1.xml' => [ '<pageMargins' ] }
|
6
|
+
ws = wb.add_worksheet
|
7
|
+
ws.fit_to_pages(3, 2)
|
8
|
+
ws.paper = 9
|
9
|
+
ws.vertical_dpi = 200
|
10
|
+
ws.write_string 0, 'A', 'Foo', nil
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'fit_to_pages05' do |wb, t|
|
14
|
+
t.ignore_elements = { 'xl/worksheets/sheet1.xml' => [ '<pageMargins' ] }
|
15
|
+
ws = wb.add_worksheet
|
16
|
+
ws.fit_to_pages(1, 0)
|
17
|
+
ws.paper = 9
|
18
|
+
ws.vertical_dpi = 200
|
19
|
+
ws.write_string 0, 'A', 'Foo', nil
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require_relative './xlsx-func-testcase'
|
2
|
+
|
3
|
+
class TestFormatting < XlsxWriterTestCase
|
4
|
+
test 'format01' do |wb|
|
5
|
+
ws1 = wb.add_worksheet
|
6
|
+
ws2 = wb.add_worksheet 'Data Sheet'
|
7
|
+
ws3 = wb.add_worksheet
|
8
|
+
|
9
|
+
wb.add_format :unused, {}
|
10
|
+
wb.add_format :format, bold: true
|
11
|
+
wb.add_format :unused2, {}
|
12
|
+
wb.add_format :unused3, {}
|
13
|
+
|
14
|
+
ws1.write_string(0, 0, 'Foo', nil)
|
15
|
+
ws1.write_number(1, 0, 123, nil)
|
16
|
+
|
17
|
+
ws3.write_string(1, 1, 'Foo', nil)
|
18
|
+
ws3.write_string(2, 1, 'Bar', :format)
|
19
|
+
ws3.write_number(3, 2, 234, nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'format02' do |wb|
|
23
|
+
ws = wb.add_worksheet
|
24
|
+
|
25
|
+
ws.set_row(0, height: 30)
|
26
|
+
wb.add_format(:format1, font_name: 'Arial',
|
27
|
+
bold: true,
|
28
|
+
align: XlsxWriter::Format::ALIGN_LEFT,
|
29
|
+
vertical_align: XlsxWriter::Format::ALIGN_VERTICAL_BOTTOM)
|
30
|
+
wb.add_format(:format2, font_name: 'Arial',
|
31
|
+
bold: true,
|
32
|
+
rotation: 90,
|
33
|
+
align: XlsxWriter::Format::ALIGN_CENTER,
|
34
|
+
vertical_align: XlsxWriter::Format::ALIGN_VERTICAL_BOTTOM)
|
35
|
+
|
36
|
+
ws.write_string(0, 0, 'Foo', :format1)
|
37
|
+
ws.write_string(0, 1, 'Bar', :format2)
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'format06' do |wb|
|
41
|
+
ws = wb.add_worksheet
|
42
|
+
|
43
|
+
wb.add_format :f1, num_format_index: 2
|
44
|
+
wb.add_format :f2, num_format_index: 12
|
45
|
+
|
46
|
+
ws.write_number(0, 0, 1.2222, nil)
|
47
|
+
ws.write_number(1, 0, 1.2222, :f1)
|
48
|
+
ws.write_number(2, 0, 1.2222, :f2)
|
49
|
+
ws.write_number(3, 0, 1.2222, nil)
|
50
|
+
ws.write_number(4, 0, 1.2222, nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'format07' do |wb|
|
54
|
+
ws = wb.add_worksheet
|
55
|
+
|
56
|
+
wb.add_format :f1, num_format: '0.000'
|
57
|
+
wb.add_format :f2, num_format: '0.00000'
|
58
|
+
wb.add_format :f3, num_format: '0.000000'
|
59
|
+
|
60
|
+
ws.write_number(0, 0, 1.2222, nil)
|
61
|
+
ws.write_number(1, 0, 1.2222, :f1)
|
62
|
+
ws.write_number(2, 0, 1.2222, :f2)
|
63
|
+
ws.write_number(3, 0, 1.2222, :f3)
|
64
|
+
ws.write_number(4, 0, 1.2222, nil)
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'format08' do |wb|
|
68
|
+
ws = wb.add_worksheet
|
69
|
+
|
70
|
+
wb.add_format :border1, bottom: XlsxWriter::Format::BORDER_THIN,
|
71
|
+
bottom_color: XlsxWriter::Format::COLOR_RED
|
72
|
+
wb.add_format :border2, top: XlsxWriter::Format::BORDER_THIN,
|
73
|
+
top_color: XlsxWriter::Format::COLOR_RED
|
74
|
+
wb.add_format :border3, left: XlsxWriter::Format::BORDER_THIN,
|
75
|
+
left_color: XlsxWriter::Format::COLOR_RED
|
76
|
+
wb.add_format :border4, right: XlsxWriter::Format::BORDER_THIN,
|
77
|
+
right_color: XlsxWriter::Format::COLOR_RED
|
78
|
+
wb.add_format :border5, border: XlsxWriter::Format::BORDER_THIN,
|
79
|
+
border_color: XlsxWriter::Format::COLOR_RED
|
80
|
+
|
81
|
+
ws.write_blank(1, 1, :border1)
|
82
|
+
ws.write_blank(3, 1, :border2)
|
83
|
+
ws.write_blank(5, 1, :border3)
|
84
|
+
ws.write_blank(7, 1, :border4)
|
85
|
+
ws.write_blank(9, 1, :border5)
|
86
|
+
end
|
87
|
+
|
88
|
+
test 'format09' do |wb|
|
89
|
+
ws = wb.add_worksheet
|
90
|
+
|
91
|
+
wb.add_format :border1, border: XlsxWriter::Format::BORDER_HAIR,
|
92
|
+
border_color: XlsxWriter::Format::COLOR_RED
|
93
|
+
wb.add_format :border2, diag_type: XlsxWriter::Format::DIAGONAL_BORDER_UP,
|
94
|
+
diag_color: XlsxWriter::Format::COLOR_RED
|
95
|
+
wb.add_format :border3, diag_type: XlsxWriter::Format::DIAGONAL_BORDER_DOWN,
|
96
|
+
diag_color: XlsxWriter::Format::COLOR_RED
|
97
|
+
wb.add_format :border4, diag_type: XlsxWriter::Format::DIAGONAL_BORDER_UP_DOWN,
|
98
|
+
diag_color: XlsxWriter::Format::COLOR_RED
|
99
|
+
|
100
|
+
ws.write_blank(1, 1, :border1)
|
101
|
+
ws.write_blank(3, 1, :border2)
|
102
|
+
ws.write_blank(5, 1, :border3)
|
103
|
+
ws.write_blank(7, 1, :border4)
|
104
|
+
end
|
105
|
+
|
106
|
+
test 'format10' do |wb|
|
107
|
+
ws = wb.add_worksheet
|
108
|
+
|
109
|
+
wb.add_format :border1, bg_color: XlsxWriter::Format::COLOR_RED
|
110
|
+
wb.add_format :border2, bg_color: XlsxWriter::Format::COLOR_YELLOW,
|
111
|
+
pattern: XlsxWriter::Format::PATTERN_DARK_VERTICAL
|
112
|
+
wb.add_format :border3, bg_color: XlsxWriter::Format::COLOR_YELLOW,
|
113
|
+
fg_color: XlsxWriter::Format::COLOR_RED,
|
114
|
+
pattern: XlsxWriter::Format::PATTERN_GRAY_0625
|
115
|
+
|
116
|
+
ws.write_blank(1, 1, :border1)
|
117
|
+
ws.write_blank(3, 1, :border2)
|
118
|
+
ws.write_blank(5, 1, :border3)
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'format12' do |wb|
|
122
|
+
ws = wb.add_worksheet
|
123
|
+
|
124
|
+
wb.add_format :top_left_bottom, bottom: XlsxWriter::Format::BORDER_THIN,
|
125
|
+
left: XlsxWriter::Format::BORDER_THIN,
|
126
|
+
top: XlsxWriter::Format::BORDER_THIN
|
127
|
+
wb.add_format :top_bottom, bottom: XlsxWriter::Format::BORDER_THIN,
|
128
|
+
top: XlsxWriter::Format::BORDER_THIN
|
129
|
+
wb.add_format :top_left, left: XlsxWriter::Format::BORDER_THIN,
|
130
|
+
top: XlsxWriter::Format::BORDER_THIN
|
131
|
+
wb.add_format :unused, left: XlsxWriter::Format::BORDER_THIN
|
132
|
+
|
133
|
+
ws.write_string(1, 'B', 'test', :top_left_bottom)
|
134
|
+
ws.write_string(1, 'D', 'test', :top_left)
|
135
|
+
ws.write_string(1, 'F', 'test', :top_bottom)
|
136
|
+
end
|
137
|
+
end
|