write_xlsx 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitattributes +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +82 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/examples/a_simple.rb +45 -0
- data/examples/array_formula.rb +33 -0
- data/examples/autofilter.rb +235 -0
- data/examples/chart_area.rb +59 -0
- data/examples/chart_bar.rb +59 -0
- data/examples/chart_column.rb +58 -0
- data/examples/chart_line.rb +59 -0
- data/examples/chart_pie.rb +49 -0
- data/examples/chart_scatter.rb +59 -0
- data/examples/chart_stock.rb +65 -0
- data/examples/colors.rb +130 -0
- data/examples/comments1.rb +12 -0
- data/examples/comments2.rb +335 -0
- data/examples/conditional_format.rb +67 -0
- data/examples/data_validate.rb +279 -0
- data/examples/defined_name.rb +28 -0
- data/examples/demo.rb +104 -0
- data/examples/diag_border.rb +26 -0
- data/examples/headers.rb +119 -0
- data/examples/hide_sheet.rb +30 -0
- data/examples/hyperlink1.rb +58 -0
- data/examples/indent.rb +28 -0
- data/examples/merge1.rb +38 -0
- data/examples/merge2.rb +48 -0
- data/examples/merge3.rb +43 -0
- data/examples/merge4.rb +82 -0
- data/examples/merge5.rb +70 -0
- data/examples/merge6.rb +48 -0
- data/examples/outline.rb +252 -0
- data/examples/properties.rb +33 -0
- data/examples/protection.rb +34 -0
- data/examples/rich_strings.rb +42 -0
- data/examples/right_to_left.rb +24 -0
- data/examples/tab_colors.rb +26 -0
- data/lib/write_xlsx.rb +77 -0
- data/lib/write_xlsx/chart.rb +3027 -0
- data/lib/write_xlsx/chart/area.rb +52 -0
- data/lib/write_xlsx/chart/bar.rb +126 -0
- data/lib/write_xlsx/chart/column.rb +132 -0
- data/lib/write_xlsx/chart/line.rb +51 -0
- data/lib/write_xlsx/chart/pie.rb +210 -0
- data/lib/write_xlsx/chart/scatter.rb +252 -0
- data/lib/write_xlsx/chart/stock.rb +134 -0
- data/lib/write_xlsx/chartsheet.rb +173 -0
- data/lib/write_xlsx/colors.rb +65 -0
- data/lib/write_xlsx/compatibility.rb +71 -0
- data/lib/write_xlsx/drawing.rb +547 -0
- data/lib/write_xlsx/format.rb +683 -0
- data/lib/write_xlsx/package/app.rb +218 -0
- data/lib/write_xlsx/package/comments.rb +221 -0
- data/lib/write_xlsx/package/content_types.rb +189 -0
- data/lib/write_xlsx/package/core.rb +196 -0
- data/lib/write_xlsx/package/packager.rb +510 -0
- data/lib/write_xlsx/package/relationships.rb +98 -0
- data/lib/write_xlsx/package/shared_strings.rb +96 -0
- data/lib/write_xlsx/package/styles.rb +705 -0
- data/lib/write_xlsx/package/theme.rb +45 -0
- data/lib/write_xlsx/package/vml.rb +386 -0
- data/lib/write_xlsx/package/xml_writer_simple.rb +90 -0
- data/lib/write_xlsx/utility.rb +113 -0
- data/lib/write_xlsx/workbook.rb +1488 -0
- data/lib/write_xlsx/worksheet.rb +6578 -0
- data/lib/write_xlsx/zip_file_utils.rb +98 -0
- data/test/chart/test_add_series.rb +113 -0
- data/test/chart/test_process_names.rb +27 -0
- data/test/chart/test_write_auto.rb +15 -0
- data/test/chart/test_write_ax_id.rb +15 -0
- data/test/chart/test_write_ax_pos.rb +15 -0
- data/test/chart/test_write_chart_space.rb +15 -0
- data/test/chart/test_write_cross_ax.rb +15 -0
- data/test/chart/test_write_crosses.rb +15 -0
- data/test/chart/test_write_format_code.rb +15 -0
- data/test/chart/test_write_idx.rb +15 -0
- data/test/chart/test_write_label_align.rb +15 -0
- data/test/chart/test_write_label_offset.rb +15 -0
- data/test/chart/test_write_lang.rb +15 -0
- data/test/chart/test_write_layout.rb +15 -0
- data/test/chart/test_write_legend.rb +16 -0
- data/test/chart/test_write_legend_pos.rb +15 -0
- data/test/chart/test_write_major_gridlines.rb +15 -0
- data/test/chart/test_write_marker.rb +17 -0
- data/test/chart/test_write_marker_size.rb +15 -0
- data/test/chart/test_write_marker_value.rb +16 -0
- data/test/chart/test_write_num_cache.rb +16 -0
- data/test/chart/test_write_num_fmt.rb +16 -0
- data/test/chart/test_write_number_format.rb +15 -0
- data/test/chart/test_write_order.rb +15 -0
- data/test/chart/test_write_orientation.rb +15 -0
- data/test/chart/test_write_page_margins.rb +15 -0
- data/test/chart/test_write_page_setup.rb +15 -0
- data/test/chart/test_write_plot_vis_only.rb +15 -0
- data/test/chart/test_write_pt.rb +16 -0
- data/test/chart/test_write_pt_count.rb +16 -0
- data/test/chart/test_write_series_formula.rb +16 -0
- data/test/chart/test_write_style.rb +41 -0
- data/test/chart/test_write_symbol.rb +16 -0
- data/test/chart/test_write_tick_lbl_pos.rb +16 -0
- data/test/chart/test_write_v.rb +16 -0
- data/test/drawing/test_drawing_chart_01.rb +50 -0
- data/test/drawing/test_drawing_image_01.rb +59 -0
- data/test/helper.rb +90 -0
- data/test/package/app/test_app01.rb +44 -0
- data/test/package/app/test_app02.rb +46 -0
- data/test/package/app/test_app03.rb +53 -0
- data/test/package/comments/test_comments01.rb +36 -0
- data/test/package/comments/test_write_text_t.rb +44 -0
- data/test/package/content_types/test_content_types.rb +35 -0
- data/test/package/content_types/test_write_default.rb +13 -0
- data/test/package/content_types/test_write_override.rb +13 -0
- data/test/package/core/test_core01.rb +28 -0
- data/test/package/core/test_core02.rb +42 -0
- data/test/package/relationships/test_relationships.rb +28 -0
- data/test/package/relationships/test_sheet_rels.rb +22 -0
- data/test/package/shared_strings/test_shared_strings01.rb +30 -0
- data/test/package/shared_strings/test_shared_strings02.rb +30 -0
- data/test/package/shared_strings/test_write_si.rb +13 -0
- data/test/package/shared_strings/test_write_sst.rb +15 -0
- data/test/package/styles/test_styles_01.rb +69 -0
- data/test/package/styles/test_styles_02.rb +104 -0
- data/test/package/styles/test_styles_03.rb +90 -0
- data/test/package/styles/test_styles_04.rb +216 -0
- data/test/package/styles/test_styles_05.rb +150 -0
- data/test/package/styles/test_styles_06.rb +104 -0
- data/test/package/styles/test_styles_07.rb +104 -0
- data/test/package/styles/test_styles_08.rb +109 -0
- data/test/package/styles/test_styles_09.rb +95 -0
- data/test/package/vml/test_vml_01.rb +42 -0
- data/test/package/vml/test_write_anchor.rb +14 -0
- data/test/package/vml/test_write_auto_fill.rb +14 -0
- data/test/package/vml/test_write_column.rb +14 -0
- data/test/package/vml/test_write_div.rb +14 -0
- data/test/package/vml/test_write_fill.rb +14 -0
- data/test/package/vml/test_write_idmap.rb +14 -0
- data/test/package/vml/test_write_move_with_cells.rb +14 -0
- data/test/package/vml/test_write_path.rb +22 -0
- data/test/package/vml/test_write_row.rb +14 -0
- data/test/package/vml/test_write_shadow.rb +14 -0
- data/test/package/vml/test_write_shapelayout.rb +14 -0
- data/test/package/vml/test_write_shapetype.rb +14 -0
- data/test/package/vml/test_write_size_with_cells.rb +14 -0
- data/test/package/vml/test_write_stroke.rb +14 -0
- data/test/package/vml/test_write_textbox.rb +14 -0
- data/test/perl_output/a_simple.xlsx +0 -0
- data/test/perl_output/array_formula.xlsx +0 -0
- data/test/perl_output/autofilter.xlsx +0 -0
- data/test/perl_output/chart_area.xlsx +0 -0
- data/test/perl_output/chart_bar.xlsx +0 -0
- data/test/perl_output/chart_column.xlsx +0 -0
- data/test/perl_output/chart_line.xlsx +0 -0
- data/test/perl_output/chart_pie.xlsx +0 -0
- data/test/perl_output/chart_scatter.xlsx +0 -0
- data/test/perl_output/chart_stock.xlsx +0 -0
- data/test/perl_output/comments1.xlsx +0 -0
- data/test/perl_output/comments2.xlsx +0 -0
- data/test/perl_output/conditional_format.xlsx +0 -0
- data/test/perl_output/data_validate.xlsx +0 -0
- data/test/perl_output/defined_name.xlsx +0 -0
- data/test/perl_output/demo.xlsx +0 -0
- data/test/perl_output/diag_border.xlsx +0 -0
- data/test/perl_output/fit_to_pages.xlsx +0 -0
- data/test/perl_output/headers.xlsx +0 -0
- data/test/perl_output/hide_sheet.xlsx +0 -0
- data/test/perl_output/hyperlink.xlsx +0 -0
- data/test/perl_output/indent.xlsx +0 -0
- data/test/perl_output/merge1.xlsx +0 -0
- data/test/perl_output/merge2.xlsx +0 -0
- data/test/perl_output/merge3.xlsx +0 -0
- data/test/perl_output/merge4.xlsx +0 -0
- data/test/perl_output/merge5.xlsx +0 -0
- data/test/perl_output/merge6.xlsx +0 -0
- data/test/perl_output/outline.xlsx +0 -0
- data/test/perl_output/print_scale.xlsx +0 -0
- data/test/perl_output/properties.xlsx +0 -0
- data/test/perl_output/protection.xlsx +0 -0
- data/test/perl_output/rich_strings.xlsx +0 -0
- data/test/perl_output/right_to_left.xlsx +0 -0
- data/test/perl_output/tab_colors.xlsx +0 -0
- data/test/test_delete_files.rb +37 -0
- data/test/test_example_match.rb +2281 -0
- data/test/test_xml_writer_simple.rb +63 -0
- data/test/workbook/test_get_chart_range.rb +59 -0
- data/test/workbook/test_sort_defined_names.rb +77 -0
- data/test/workbook/test_workbook_01.rb +29 -0
- data/test/workbook/test_workbook_02.rb +31 -0
- data/test/workbook/test_workbook_03.rb +31 -0
- data/test/workbook/test_workbook_new.rb +18 -0
- data/test/workbook/test_write_defined_name.rb +17 -0
- data/test/workbook/test_write_defined_names.rb +41 -0
- data/test/worksheet/test_calculate_spans.rb +58 -0
- data/test/worksheet/test_convert_date_time_01.rb +439 -0
- data/test/worksheet/test_convert_date_time_02.rb +478 -0
- data/test/worksheet/test_convert_date_time_03.rb +435 -0
- data/test/worksheet/test_extract_filter_tokens.rb +109 -0
- data/test/worksheet/test_parse_filter_expression.rb +143 -0
- data/test/worksheet/test_position_object.rb +50 -0
- data/test/worksheet/test_repeat_formula.rb +55 -0
- data/test/worksheet/test_worksheet_01.rb +32 -0
- data/test/worksheet/test_worksheet_02.rb +38 -0
- data/test/worksheet/test_worksheet_03.rb +44 -0
- data/test/worksheet/test_worksheet_04.rb +45 -0
- data/test/worksheet/test_write_array_formula_01.rb +99 -0
- data/test/worksheet/test_write_autofilter.rb +260 -0
- data/test/worksheet/test_write_brk.rb +18 -0
- data/test/worksheet/test_write_cell.rb +49 -0
- data/test/worksheet/test_write_cell_value.rb +33 -0
- data/test/worksheet/test_write_col_breaks.rb +27 -0
- data/test/worksheet/test_write_col_info.rb +95 -0
- data/test/worksheet/test_write_conditional_formatting.rb +72 -0
- data/test/worksheet/test_write_custom_filter.rb +18 -0
- data/test/worksheet/test_write_custom_filters.rb +25 -0
- data/test/worksheet/test_write_data_validation_01.rb +113 -0
- data/test/worksheet/test_write_data_validation_02.rb +528 -0
- data/test/worksheet/test_write_dimension.rb +94 -0
- data/test/worksheet/test_write_ext.rb +18 -0
- data/test/worksheet/test_write_ext_lst.rb +18 -0
- data/test/worksheet/test_write_filter.rb +18 -0
- data/test/worksheet/test_write_filter_column.rb +18 -0
- data/test/worksheet/test_write_filters.rb +32 -0
- data/test/worksheet/test_write_header_footer.rb +53 -0
- data/test/worksheet/test_write_hyperlink.rb +39 -0
- data/test/worksheet/test_write_hyperlinks.rb +27 -0
- data/test/worksheet/test_write_legacy_drawing.rb +19 -0
- data/test/worksheet/test_write_merge_cell.rb +18 -0
- data/test/worksheet/test_write_merge_cells.rb +192 -0
- data/test/worksheet/test_write_methods.rb +353 -0
- data/test/worksheet/test_write_mx_plv.rb +19 -0
- data/test/worksheet/test_write_page_margins.rb +98 -0
- data/test/worksheet/test_write_page_set_up_pr.rb +19 -0
- data/test/worksheet/test_write_page_setup.rb +54 -0
- data/test/worksheet/test_write_pane.rb +123 -0
- data/test/worksheet/test_write_phonetic_pr.rb +19 -0
- data/test/worksheet/test_write_print_options.rb +77 -0
- data/test/worksheet/test_write_row_breaks.rb +27 -0
- data/test/worksheet/test_write_row_element.rb +69 -0
- data/test/worksheet/test_write_selection.rb +18 -0
- data/test/worksheet/test_write_sheet_calc_pr.rb +18 -0
- data/test/worksheet/test_write_sheet_data.rb +18 -0
- data/test/worksheet/test_write_sheet_format_pr.rb +18 -0
- data/test/worksheet/test_write_sheet_pr.rb +36 -0
- data/test/worksheet/test_write_sheet_protection.rb +174 -0
- data/test/worksheet/test_write_sheet_view.rb +62 -0
- data/test/worksheet/test_write_sheet_view1.rb +64 -0
- data/test/worksheet/test_write_sheet_view2.rb +56 -0
- data/test/worksheet/test_write_sheet_view3.rb +83 -0
- data/test/worksheet/test_write_sheet_view4.rb +83 -0
- data/test/worksheet/test_write_sheet_view5.rb +74 -0
- data/test/worksheet/test_write_sheet_view6.rb +51 -0
- data/test/worksheet/test_write_sheet_view7.rb +71 -0
- data/test/worksheet/test_write_sheet_view8.rb +51 -0
- data/test/worksheet/test_write_sheet_view9.rb +51 -0
- data/test/worksheet/test_write_tab_color.rb +23 -0
- data/test/worksheet/test_write_worksheet.rb +19 -0
- data/write_xlsx.gemspec +308 -0
- metadata +363 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/core'
|
4
|
+
|
5
|
+
class TestCore01 < Test::Unit::TestCase
|
6
|
+
def test_assemble_xml_file
|
7
|
+
properties = {
|
8
|
+
:author => 'A User',
|
9
|
+
:created => Time.local(2010, 1, 1, 0, 0, 0)
|
10
|
+
}
|
11
|
+
|
12
|
+
@obj = Writexlsx::Package::Core.new
|
13
|
+
@obj.set_properties(properties)
|
14
|
+
@obj.assemble_xml_file
|
15
|
+
result = got_to_array(@obj.xml_str)
|
16
|
+
expected = expected_to_array(<<EOS
|
17
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
18
|
+
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
19
|
+
<dc:creator>A User</dc:creator>
|
20
|
+
<cp:lastModifiedBy>A User</cp:lastModifiedBy>
|
21
|
+
<dcterms:created xsi:type="dcterms:W3CDTF">2010-01-01T00:00:00Z</dcterms:created>
|
22
|
+
<dcterms:modified xsi:type="dcterms:W3CDTF">2010-01-01T00:00:00Z</dcterms:modified>
|
23
|
+
</cp:coreProperties>
|
24
|
+
EOS
|
25
|
+
)
|
26
|
+
assert_equal(expected, result)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/core'
|
4
|
+
|
5
|
+
class TestCore02 < Test::Unit::TestCase
|
6
|
+
def test_assemble_xml_file
|
7
|
+
properties = {
|
8
|
+
:title => 'This is an example spreadsheet',
|
9
|
+
:subject => 'With document properties',
|
10
|
+
:author => 'John McNamara',
|
11
|
+
:manager => 'Dr. Heinz Doofenshmirtz',
|
12
|
+
:company => 'of Wolves',
|
13
|
+
:category => 'Example spreadsheets',
|
14
|
+
:keywords => 'Sample, Example, Properties',
|
15
|
+
:comments => 'Created with Ruby and WriteXLSX',
|
16
|
+
:status => 'Quo',
|
17
|
+
:created => Time.local(2011, 4, 6, 19, 45, 15)
|
18
|
+
}
|
19
|
+
|
20
|
+
@obj = Writexlsx::Package::Core.new
|
21
|
+
@obj.set_properties(properties)
|
22
|
+
@obj.assemble_xml_file
|
23
|
+
result = got_to_array(@obj.xml_str)
|
24
|
+
expected = expected_to_array(<<EOS
|
25
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
26
|
+
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
27
|
+
<dc:title>This is an example spreadsheet</dc:title>
|
28
|
+
<dc:subject>With document properties</dc:subject>
|
29
|
+
<dc:creator>John McNamara</dc:creator>
|
30
|
+
<cp:keywords>Sample, Example, Properties</cp:keywords>
|
31
|
+
<dc:description>Created with Ruby and WriteXLSX</dc:description>
|
32
|
+
<cp:lastModifiedBy>John McNamara</cp:lastModifiedBy>
|
33
|
+
<dcterms:created xsi:type="dcterms:W3CDTF">2011-04-06T19:45:15Z</dcterms:created>
|
34
|
+
<dcterms:modified xsi:type="dcterms:W3CDTF">2011-04-06T19:45:15Z</dcterms:modified>
|
35
|
+
<cp:category>Example spreadsheets</cp:category>
|
36
|
+
<cp:contentStatus>Quo</cp:contentStatus>
|
37
|
+
</cp:coreProperties>
|
38
|
+
EOS
|
39
|
+
)
|
40
|
+
assert_equal(expected, result)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/relationships'
|
4
|
+
|
5
|
+
class TestRelationships < Test::Unit::TestCase
|
6
|
+
def test_assemble_xml_file
|
7
|
+
@obj = Writexlsx::Package::Relationships.new
|
8
|
+
@obj.add_document_relationship('/worksheet', 'worksheets/sheet1.xml')
|
9
|
+
@obj.add_document_relationship('/theme', 'theme/theme1.xml')
|
10
|
+
@obj.add_document_relationship('/styles', 'styles.xml')
|
11
|
+
@obj.add_document_relationship('/sharedStrings', 'sharedStrings.xml')
|
12
|
+
@obj.add_document_relationship('/calcChain', 'calcChain.xml')
|
13
|
+
@obj.assemble_xml_file
|
14
|
+
result = got_to_array(@obj.xml_str)
|
15
|
+
expected = expected_to_array(<<EOS
|
16
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
17
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
18
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
|
19
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
|
20
|
+
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
|
21
|
+
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>
|
22
|
+
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain" Target="calcChain.xml"/>
|
23
|
+
</Relationships>
|
24
|
+
EOS
|
25
|
+
)
|
26
|
+
assert_equal(expected, result)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/relationships'
|
4
|
+
|
5
|
+
class TestSheetRels < Test::Unit::TestCase
|
6
|
+
def test_sheet_rels
|
7
|
+
@obj = Writexlsx::Package::Relationships.new
|
8
|
+
@obj.add_worksheet_relationship('/hyperlink', 'www.foo.com', 'External')
|
9
|
+
@obj.add_worksheet_relationship('/hyperlink', 'link00.xlsx', 'External')
|
10
|
+
@obj.assemble_xml_file
|
11
|
+
result = got_to_array(@obj.xml_str)
|
12
|
+
expected = expected_to_array(<<EOS
|
13
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
14
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
15
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="www.foo.com" TargetMode="External"/>
|
16
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="link00.xlsx" TargetMode="External"/>
|
17
|
+
</Relationships>
|
18
|
+
EOS
|
19
|
+
)
|
20
|
+
assert_equal(expected, result)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/shared_strings'
|
4
|
+
|
5
|
+
class TestSharedStrings01 < Test::Unit::TestCase
|
6
|
+
def test_shared_strings01
|
7
|
+
@obj = Writexlsx::Package::SharedStrings.new
|
8
|
+
@obj.string_count = 7
|
9
|
+
@obj.unique_count = 3
|
10
|
+
@obj.add_strings(['neptune', 'mars', 'venus'])
|
11
|
+
@obj.assemble_xml_file
|
12
|
+
result = got_to_array(@obj.xml_str)
|
13
|
+
expected = expected_to_array(<<EOS
|
14
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
15
|
+
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="7" uniqueCount="3">
|
16
|
+
<si>
|
17
|
+
<t>neptune</t>
|
18
|
+
</si>
|
19
|
+
<si>
|
20
|
+
<t>mars</t>
|
21
|
+
</si>
|
22
|
+
<si>
|
23
|
+
<t>venus</t>
|
24
|
+
</si>
|
25
|
+
</sst>
|
26
|
+
EOS
|
27
|
+
)
|
28
|
+
assert_equal(expected, result)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/shared_strings'
|
4
|
+
|
5
|
+
class TestSharedStrings02 < Test::Unit::TestCase
|
6
|
+
def test_shared_strings02
|
7
|
+
@obj = Writexlsx::Package::SharedStrings.new
|
8
|
+
@obj.string_count = 3
|
9
|
+
@obj.unique_count = 3
|
10
|
+
@obj.add_strings(['abcdefg', ' abcdefg', 'abcdefg '])
|
11
|
+
@obj.assemble_xml_file
|
12
|
+
result = got_to_array(@obj.xml_str)
|
13
|
+
expected = expected_to_array(<<EOS
|
14
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
15
|
+
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="3" uniqueCount="3">
|
16
|
+
<si>
|
17
|
+
<t>abcdefg</t>
|
18
|
+
</si>
|
19
|
+
<si>
|
20
|
+
<t xml:space="preserve"> abcdefg</t>
|
21
|
+
</si>
|
22
|
+
<si>
|
23
|
+
<t xml:space="preserve">abcdefg </t>
|
24
|
+
</si>
|
25
|
+
</sst>
|
26
|
+
EOS
|
27
|
+
)
|
28
|
+
assert_equal(expected, result)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/shared_strings'
|
4
|
+
|
5
|
+
class TestWriteSi < Test::Unit::TestCase
|
6
|
+
def test_write_si
|
7
|
+
@obj = Writexlsx::Package::SharedStrings.new
|
8
|
+
@obj.__send__('write_si', 'neptune')
|
9
|
+
result = @obj.instance_variable_get(:@writer).string
|
10
|
+
expected = '<si><t>neptune</t></si>'
|
11
|
+
assert_equal(expected, result)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/package/shared_strings'
|
4
|
+
|
5
|
+
class TestWriteSst < Test::Unit::TestCase
|
6
|
+
def test_write_sst
|
7
|
+
@obj = Writexlsx::Package::SharedStrings.new
|
8
|
+
@obj.string_count = 7
|
9
|
+
@obj.unique_count = 3
|
10
|
+
@obj.__send__('write_sst')
|
11
|
+
result = @obj.instance_variable_get(:@writer).string
|
12
|
+
expected = '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="7" uniqueCount="3">'
|
13
|
+
assert_equal(expected, result)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class TestStyles01 < Test::Unit::TestCase
|
7
|
+
def test_styles_01
|
8
|
+
workbook = WriteXLSX.new(StringIO.new)
|
9
|
+
workbook.__send__('prepare_format_properties')
|
10
|
+
|
11
|
+
@style = Writexlsx::Package::Styles.new
|
12
|
+
@style.set_style_properties(
|
13
|
+
workbook.xf_formats,
|
14
|
+
workbook.palette,
|
15
|
+
workbook.font_count,
|
16
|
+
workbook.num_format_count,
|
17
|
+
workbook.border_count,
|
18
|
+
workbook.fill_count,
|
19
|
+
workbook.custom_colors,
|
20
|
+
workbook.dxf_formats
|
21
|
+
)
|
22
|
+
@style.assemble_xml_file
|
23
|
+
result = got_to_array(@style.xml_str)
|
24
|
+
expected = expected_to_array(<<EOS
|
25
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
26
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
27
|
+
<fonts count="1">
|
28
|
+
<font>
|
29
|
+
<sz val="11"/>
|
30
|
+
<color theme="1"/>
|
31
|
+
<name val="Calibri"/>
|
32
|
+
<family val="2"/>
|
33
|
+
<scheme val="minor"/>
|
34
|
+
</font>
|
35
|
+
</fonts>
|
36
|
+
<fills count="2">
|
37
|
+
<fill>
|
38
|
+
<patternFill patternType="none"/>
|
39
|
+
</fill>
|
40
|
+
<fill>
|
41
|
+
<patternFill patternType="gray125"/>
|
42
|
+
</fill>
|
43
|
+
</fills>
|
44
|
+
<borders count="1">
|
45
|
+
<border>
|
46
|
+
<left/>
|
47
|
+
<right/>
|
48
|
+
<top/>
|
49
|
+
<bottom/>
|
50
|
+
<diagonal/>
|
51
|
+
</border>
|
52
|
+
</borders>
|
53
|
+
<cellStyleXfs count="1">
|
54
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
55
|
+
</cellStyleXfs>
|
56
|
+
<cellXfs count="1">
|
57
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
58
|
+
</cellXfs>
|
59
|
+
<cellStyles count="1">
|
60
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
61
|
+
</cellStyles>
|
62
|
+
<dxfs count="0"/>
|
63
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
64
|
+
</styleSheet>
|
65
|
+
EOS
|
66
|
+
)
|
67
|
+
assert_equal(expected, result)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/workbook'
|
4
|
+
require 'write_xlsx/package/styles'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
class TestStyles02 < Test::Unit::TestCase
|
8
|
+
def test_styles_02
|
9
|
+
workbook = WriteXLSX.new(StringIO.new)
|
10
|
+
|
11
|
+
format1 = workbook.add_format(:bold => 1)
|
12
|
+
format2 = workbook.add_format(:italic => 1)
|
13
|
+
format3 = workbook.add_format(:bold => 1, :italic => 1)
|
14
|
+
|
15
|
+
workbook.__send__('set_default_xf_indices')
|
16
|
+
workbook.__send__('prepare_format_properties')
|
17
|
+
|
18
|
+
@style = Writexlsx::Package::Styles.new
|
19
|
+
@style.set_style_properties(
|
20
|
+
workbook.xf_formats,
|
21
|
+
workbook.palette,
|
22
|
+
workbook.font_count,
|
23
|
+
workbook.num_format_count,
|
24
|
+
workbook.border_count,
|
25
|
+
workbook.fill_count,
|
26
|
+
workbook.custom_colors,
|
27
|
+
workbook.dxf_formats
|
28
|
+
)
|
29
|
+
@style.assemble_xml_file
|
30
|
+
result = got_to_array(@style.xml_str)
|
31
|
+
expected = expected_to_array(<<EOS
|
32
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
33
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
34
|
+
<fonts count="4">
|
35
|
+
<font>
|
36
|
+
<sz val="11"/>
|
37
|
+
<color theme="1"/>
|
38
|
+
<name val="Calibri"/>
|
39
|
+
<family val="2"/>
|
40
|
+
<scheme val="minor"/>
|
41
|
+
</font>
|
42
|
+
<font>
|
43
|
+
<b/>
|
44
|
+
<sz val="11"/>
|
45
|
+
<color theme="1"/>
|
46
|
+
<name val="Calibri"/>
|
47
|
+
<family val="2"/>
|
48
|
+
<scheme val="minor"/>
|
49
|
+
</font>
|
50
|
+
<font>
|
51
|
+
<i/>
|
52
|
+
<sz val="11"/>
|
53
|
+
<color theme="1"/>
|
54
|
+
<name val="Calibri"/>
|
55
|
+
<family val="2"/>
|
56
|
+
<scheme val="minor"/>
|
57
|
+
</font>
|
58
|
+
<font>
|
59
|
+
<b/>
|
60
|
+
<i/>
|
61
|
+
<sz val="11"/>
|
62
|
+
<color theme="1"/>
|
63
|
+
<name val="Calibri"/>
|
64
|
+
<family val="2"/>
|
65
|
+
<scheme val="minor"/>
|
66
|
+
</font>
|
67
|
+
</fonts>
|
68
|
+
<fills count="2">
|
69
|
+
<fill>
|
70
|
+
<patternFill patternType="none"/>
|
71
|
+
</fill>
|
72
|
+
<fill>
|
73
|
+
<patternFill patternType="gray125"/>
|
74
|
+
</fill>
|
75
|
+
</fills>
|
76
|
+
<borders count="1">
|
77
|
+
<border>
|
78
|
+
<left/>
|
79
|
+
<right/>
|
80
|
+
<top/>
|
81
|
+
<bottom/>
|
82
|
+
<diagonal/>
|
83
|
+
</border>
|
84
|
+
</borders>
|
85
|
+
<cellStyleXfs count="1">
|
86
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
87
|
+
</cellStyleXfs>
|
88
|
+
<cellXfs count="4">
|
89
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
90
|
+
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
91
|
+
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
92
|
+
<xf numFmtId="0" fontId="3" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
93
|
+
</cellXfs>
|
94
|
+
<cellStyles count="1">
|
95
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
96
|
+
</cellStyles>
|
97
|
+
<dxfs count="0"/>
|
98
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
99
|
+
</styleSheet>
|
100
|
+
EOS
|
101
|
+
)
|
102
|
+
assert_equal(expected, result)
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
require 'write_xlsx/workbook'
|
4
|
+
require 'write_xlsx/package/styles'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
class TestStyles03 < Test::Unit::TestCase
|
8
|
+
def test_styles_03
|
9
|
+
workbook = WriteXLSX.new(StringIO.new)
|
10
|
+
|
11
|
+
format1 = workbook.add_format(:num_format => 2)
|
12
|
+
format2 = workbook.add_format(:num_format => 2, :bold => 1)
|
13
|
+
format3 = workbook.add_format(:num_format => '0.0')
|
14
|
+
|
15
|
+
workbook.__send__('set_default_xf_indices')
|
16
|
+
workbook.__send__('prepare_format_properties')
|
17
|
+
|
18
|
+
@style = Writexlsx::Package::Styles.new
|
19
|
+
@style.set_style_properties(
|
20
|
+
workbook.xf_formats,
|
21
|
+
workbook.palette,
|
22
|
+
workbook.font_count,
|
23
|
+
workbook.num_format_count,
|
24
|
+
workbook.border_count,
|
25
|
+
workbook.fill_count,
|
26
|
+
workbook.custom_colors,
|
27
|
+
workbook.dxf_formats
|
28
|
+
)
|
29
|
+
@style.assemble_xml_file
|
30
|
+
result = got_to_array(@style.xml_str)
|
31
|
+
expected = expected_to_array(<<EOS
|
32
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
33
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
34
|
+
<numFmts count="1">
|
35
|
+
<numFmt numFmtId="164" formatCode="0.0"/>
|
36
|
+
</numFmts>
|
37
|
+
<fonts count="2">
|
38
|
+
<font>
|
39
|
+
<sz val="11"/>
|
40
|
+
<color theme="1"/>
|
41
|
+
<name val="Calibri"/>
|
42
|
+
<family val="2"/>
|
43
|
+
<scheme val="minor"/>
|
44
|
+
</font>
|
45
|
+
<font>
|
46
|
+
<b/>
|
47
|
+
<sz val="11"/>
|
48
|
+
<color theme="1"/>
|
49
|
+
<name val="Calibri"/>
|
50
|
+
<family val="2"/>
|
51
|
+
<scheme val="minor"/>
|
52
|
+
</font>
|
53
|
+
</fonts>
|
54
|
+
<fills count="2">
|
55
|
+
<fill>
|
56
|
+
<patternFill patternType="none"/>
|
57
|
+
</fill>
|
58
|
+
<fill>
|
59
|
+
<patternFill patternType="gray125"/>
|
60
|
+
</fill>
|
61
|
+
</fills>
|
62
|
+
<borders count="1">
|
63
|
+
<border>
|
64
|
+
<left/>
|
65
|
+
<right/>
|
66
|
+
<top/>
|
67
|
+
<bottom/>
|
68
|
+
<diagonal/>
|
69
|
+
</border>
|
70
|
+
</borders>
|
71
|
+
<cellStyleXfs count="1">
|
72
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
73
|
+
</cellStyleXfs>
|
74
|
+
<cellXfs count="4">
|
75
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
76
|
+
<xf numFmtId="2" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
|
77
|
+
<xf numFmtId="2" fontId="1" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyFont="1"/>
|
78
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
|
79
|
+
</cellXfs>
|
80
|
+
<cellStyles count="1">
|
81
|
+
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
82
|
+
</cellStyles>
|
83
|
+
<dxfs count="0"/>
|
84
|
+
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
85
|
+
</styleSheet>
|
86
|
+
EOS
|
87
|
+
)
|
88
|
+
assert_equal(expected, result)
|
89
|
+
end
|
90
|
+
end
|