write_xlsx 0.0.2
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/.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,45 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require 'write_xlsx/package/xml_writer_simple'
|
|
4
|
+
require 'write_xlsx/utility'
|
|
5
|
+
|
|
6
|
+
module Writexlsx
|
|
7
|
+
module Package
|
|
8
|
+
class Theme
|
|
9
|
+
|
|
10
|
+
include Writexlsx::Utility
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@writer = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def assemble_xml_file
|
|
17
|
+
return unless @writer
|
|
18
|
+
write_theme_file
|
|
19
|
+
@writer.write("\n")
|
|
20
|
+
@writer.close
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Set the filehandle only. This class doesn't use a real XML writer class.
|
|
25
|
+
#
|
|
26
|
+
def set_xml_writer(filename)
|
|
27
|
+
fh = open(filename, 'wb')
|
|
28
|
+
|
|
29
|
+
@writer = fh
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# Write a default theme.xml file.
|
|
36
|
+
#
|
|
37
|
+
def write_theme_file
|
|
38
|
+
theme =
|
|
39
|
+
%Q{<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
40
|
+
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>}
|
|
41
|
+
@writer.write(theme)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'write_xlsx/package/xml_writer_simple'
|
|
3
|
+
require 'write_xlsx/utility'
|
|
4
|
+
|
|
5
|
+
module Writexlsx
|
|
6
|
+
module Package
|
|
7
|
+
class VML
|
|
8
|
+
|
|
9
|
+
include Writexlsx::Utility
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@writer = Package::XMLWriterSimple.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def set_xml_writer(filename)
|
|
16
|
+
@writer.set_xml_writer(filename)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def assemble_xml_file(data_id, vml_shape_id, comments_data)
|
|
20
|
+
return unless @writer
|
|
21
|
+
|
|
22
|
+
write_xml_namespace
|
|
23
|
+
|
|
24
|
+
# Write the o:shapelayout element.
|
|
25
|
+
write_shapelayout(data_id)
|
|
26
|
+
|
|
27
|
+
# Write the v:shapetype element.
|
|
28
|
+
write_shapetype
|
|
29
|
+
|
|
30
|
+
z_index = 1
|
|
31
|
+
comments_data.each do |comment|
|
|
32
|
+
# Write the v:shape element.
|
|
33
|
+
vml_shape_id += 1
|
|
34
|
+
write_shape(vml_shape_id, z_index, comment)
|
|
35
|
+
z_index += 1
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
@writer.end_tag('xml')
|
|
39
|
+
@writer.crlf
|
|
40
|
+
@writer.close
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Convert comment vertices from pixels to points.
|
|
47
|
+
#
|
|
48
|
+
def pixels_to_points(vertices)
|
|
49
|
+
col_start, row_start, x1, y1,
|
|
50
|
+
col_end, row_end, x2, y2,
|
|
51
|
+
left, top, width, height = vertices.flatten
|
|
52
|
+
|
|
53
|
+
left *= 0.75
|
|
54
|
+
top *= 0.75
|
|
55
|
+
width *= 0.75
|
|
56
|
+
height *= 0.75
|
|
57
|
+
|
|
58
|
+
[left, top, width, height]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Write the <xml> element. This is the root element of VML.
|
|
63
|
+
#
|
|
64
|
+
def write_xml_namespace
|
|
65
|
+
schema = 'urn:schemas-microsoft-com:'
|
|
66
|
+
xmlns = schema + 'vml'
|
|
67
|
+
xmlns_o = schema + 'office:office'
|
|
68
|
+
xmlns_x = schema + 'office:excel'
|
|
69
|
+
|
|
70
|
+
attributes = [
|
|
71
|
+
'xmlns:v', xmlns,
|
|
72
|
+
'xmlns:o', xmlns_o,
|
|
73
|
+
'xmlns:x', xmlns_x
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
@writer.start_tag('xml', attributes)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
#
|
|
80
|
+
# Write the <o:shapelayout> element.
|
|
81
|
+
#
|
|
82
|
+
def write_shapelayout(data_id)
|
|
83
|
+
ext = 'edit'
|
|
84
|
+
|
|
85
|
+
attributes = ['v:ext', ext]
|
|
86
|
+
|
|
87
|
+
@writer.start_tag('o:shapelayout', attributes)
|
|
88
|
+
|
|
89
|
+
# Write the o:idmap element.
|
|
90
|
+
write_idmap(data_id)
|
|
91
|
+
|
|
92
|
+
@writer.end_tag('o:shapelayout')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
#
|
|
96
|
+
# Write the <o:idmap> element.
|
|
97
|
+
#
|
|
98
|
+
def write_idmap(data_id)
|
|
99
|
+
ext = 'edit'
|
|
100
|
+
|
|
101
|
+
attributes = [
|
|
102
|
+
'v:ext', ext,
|
|
103
|
+
'data', data_id
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
@writer.empty_tag('o:idmap', attributes)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Write the <v:shapetype> element.
|
|
111
|
+
#
|
|
112
|
+
def write_shapetype
|
|
113
|
+
id = '_x0000_t202'
|
|
114
|
+
coordsize = '21600,21600'
|
|
115
|
+
spt = 202
|
|
116
|
+
path = 'm,l,21600r21600,l21600,xe'
|
|
117
|
+
|
|
118
|
+
attributes = [
|
|
119
|
+
'id', id,
|
|
120
|
+
'coordsize', coordsize,
|
|
121
|
+
'o:spt', spt,
|
|
122
|
+
'path', path
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
@writer.start_tag('v:shapetype', attributes)
|
|
126
|
+
|
|
127
|
+
# Write the v:stroke element.
|
|
128
|
+
write_stroke
|
|
129
|
+
|
|
130
|
+
# Write the v:path element.
|
|
131
|
+
write_path('t', 'rect')
|
|
132
|
+
|
|
133
|
+
@writer.end_tag('v:shapetype')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# Write the <v:stroke> element.
|
|
138
|
+
#
|
|
139
|
+
def write_stroke
|
|
140
|
+
joinstyle = 'miter'
|
|
141
|
+
|
|
142
|
+
attributes = ['joinstyle', joinstyle]
|
|
143
|
+
|
|
144
|
+
@writer.empty_tag('v:stroke', attributes)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
#
|
|
148
|
+
# Write the <v:path> element.
|
|
149
|
+
#
|
|
150
|
+
def write_path(gradientshapeok, connecttype)
|
|
151
|
+
attributes = []
|
|
152
|
+
|
|
153
|
+
attributes << 'gradientshapeok' << 't' if gradientshapeok
|
|
154
|
+
attributes << 'o:connecttype' << connecttype
|
|
155
|
+
|
|
156
|
+
@writer.empty_tag('v:path', attributes)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# Write the <v:shape> element.
|
|
161
|
+
#
|
|
162
|
+
def write_shape(id, z_index, comment)
|
|
163
|
+
type = '#_x0000_t202'
|
|
164
|
+
insetmode = 'auto'
|
|
165
|
+
visibility = 'hidden'
|
|
166
|
+
|
|
167
|
+
# Set the shape index.
|
|
168
|
+
id = '_x0000_s' + id.to_s
|
|
169
|
+
|
|
170
|
+
# Get the comment parameters
|
|
171
|
+
row = comment[0]
|
|
172
|
+
col = comment[1]
|
|
173
|
+
string = comment[2]
|
|
174
|
+
author = comment[3]
|
|
175
|
+
visible = comment[4]
|
|
176
|
+
fillcolor = comment[5]
|
|
177
|
+
vertices = comment[6]
|
|
178
|
+
|
|
179
|
+
left, top, width, height = pixels_to_points(vertices)
|
|
180
|
+
|
|
181
|
+
# Set the visibility.
|
|
182
|
+
visibility = 'visible' if visible != 0 && !visible.nil?
|
|
183
|
+
|
|
184
|
+
left_str = float_to_str(left)
|
|
185
|
+
top_str = float_to_str(top)
|
|
186
|
+
width_str = float_to_str(width)
|
|
187
|
+
height_str = float_to_str(height)
|
|
188
|
+
z_index_str = float_to_str(z_index)
|
|
189
|
+
|
|
190
|
+
style =
|
|
191
|
+
'position:absolute;' +
|
|
192
|
+
'margin-left:' +
|
|
193
|
+
left_str + 'pt;' +
|
|
194
|
+
'margin-top:' +
|
|
195
|
+
top_str + 'pt;' +
|
|
196
|
+
'width:' +
|
|
197
|
+
width_str + 'pt;' +
|
|
198
|
+
'height:' +
|
|
199
|
+
height_str + 'pt;' +
|
|
200
|
+
'z-index:' +
|
|
201
|
+
z_index_str + ';' +
|
|
202
|
+
'visibility:' +
|
|
203
|
+
visibility
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
attributes = [
|
|
207
|
+
'id', id,
|
|
208
|
+
'type', type,
|
|
209
|
+
'style', style,
|
|
210
|
+
'fillcolor', fillcolor,
|
|
211
|
+
'o:insetmode', insetmode
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
@writer.start_tag('v:shape', attributes)
|
|
215
|
+
|
|
216
|
+
# Write the v:fill element.
|
|
217
|
+
write_fill
|
|
218
|
+
|
|
219
|
+
# Write the v:shadow element.
|
|
220
|
+
write_shadow
|
|
221
|
+
|
|
222
|
+
# Write the v:path element.
|
|
223
|
+
write_path(nil, 'none')
|
|
224
|
+
|
|
225
|
+
# Write the v:textbox element.
|
|
226
|
+
write_textbox
|
|
227
|
+
|
|
228
|
+
# Write the x:ClientData element.
|
|
229
|
+
write_client_data(row, col, visible, vertices)
|
|
230
|
+
|
|
231
|
+
@writer.end_tag('v:shape')
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def float_to_str(float)
|
|
235
|
+
return '' unless float
|
|
236
|
+
if float == float.to_i
|
|
237
|
+
float.to_i.to_s
|
|
238
|
+
else
|
|
239
|
+
float.to_s
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
#
|
|
244
|
+
# Write the <v:fill> element.
|
|
245
|
+
#
|
|
246
|
+
def write_fill
|
|
247
|
+
color_2 = '#ffffe1'
|
|
248
|
+
attributes = ['color2', color_2]
|
|
249
|
+
|
|
250
|
+
@writer.empty_tag('v:fill', attributes)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
#
|
|
254
|
+
# Write the <v:shadow> element.
|
|
255
|
+
#
|
|
256
|
+
def write_shadow
|
|
257
|
+
on = 't'
|
|
258
|
+
color = 'black'
|
|
259
|
+
obscured = 't'
|
|
260
|
+
|
|
261
|
+
attributes = [
|
|
262
|
+
'on', on,
|
|
263
|
+
'color', color,
|
|
264
|
+
'obscured', obscured
|
|
265
|
+
]
|
|
266
|
+
|
|
267
|
+
@writer.empty_tag('v:shadow', attributes)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
#
|
|
271
|
+
# Write the <v:textbox> element.
|
|
272
|
+
#
|
|
273
|
+
def write_textbox
|
|
274
|
+
style = 'mso-direction-alt:auto'
|
|
275
|
+
|
|
276
|
+
attributes = ['style', style]
|
|
277
|
+
|
|
278
|
+
@writer.start_tag('v:textbox', attributes)
|
|
279
|
+
|
|
280
|
+
# Write the div element.
|
|
281
|
+
write_div
|
|
282
|
+
|
|
283
|
+
@writer.end_tag('v:textbox')
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
#
|
|
287
|
+
# Write the <div> element.
|
|
288
|
+
#
|
|
289
|
+
def write_div
|
|
290
|
+
style = 'text-align:left'
|
|
291
|
+
attributes = ['style', style]
|
|
292
|
+
|
|
293
|
+
@writer.start_tag('div', attributes)
|
|
294
|
+
@writer.end_tag('div')
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
#
|
|
298
|
+
# Write the <x:ClientData> element.
|
|
299
|
+
#
|
|
300
|
+
def write_client_data(row, col, visible, vertices)
|
|
301
|
+
object_type = 'Note'
|
|
302
|
+
|
|
303
|
+
attributes = ['ObjectType', object_type]
|
|
304
|
+
|
|
305
|
+
@writer.start_tag('x:ClientData', attributes)
|
|
306
|
+
|
|
307
|
+
# Write the x:MoveWithCells element.
|
|
308
|
+
write_move_with_cells
|
|
309
|
+
|
|
310
|
+
# Write the x:SizeWithCells element.
|
|
311
|
+
write_size_with_cells
|
|
312
|
+
|
|
313
|
+
# Write the x:Anchor element.
|
|
314
|
+
write_anchor(vertices)
|
|
315
|
+
|
|
316
|
+
# Write the x:AutoFill element.
|
|
317
|
+
write_auto_fill
|
|
318
|
+
|
|
319
|
+
# Write the x:Row element.
|
|
320
|
+
write_row(row)
|
|
321
|
+
|
|
322
|
+
# Write the x:Column element.
|
|
323
|
+
write_column(col)
|
|
324
|
+
|
|
325
|
+
# Write the x:Visible element.
|
|
326
|
+
write_visible if visible != 0 && !visible.nil?
|
|
327
|
+
|
|
328
|
+
@writer.end_tag('x:ClientData')
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
#
|
|
332
|
+
# Write the <x:MoveWithCells> element.
|
|
333
|
+
#
|
|
334
|
+
def write_move_with_cells
|
|
335
|
+
@writer.empty_tag('x:MoveWithCells')
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
#
|
|
339
|
+
# Write the <x:SizeWithCells> element.
|
|
340
|
+
#
|
|
341
|
+
def write_size_with_cells
|
|
342
|
+
@writer.empty_tag('x:SizeWithCells')
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
#
|
|
346
|
+
# Write the <x:Visible> element.
|
|
347
|
+
#
|
|
348
|
+
def write_visible
|
|
349
|
+
@writer.empty_tag('x:Visible')
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
#
|
|
353
|
+
# Write the <x:Anchor> element.
|
|
354
|
+
#
|
|
355
|
+
def write_anchor(vertices)
|
|
356
|
+
col_start, row_start, x1, y1, col_end, row_end, x2, y2 = vertices
|
|
357
|
+
data = [col_start, x1, row_start, y1, col_end, x2, row_end, y2].join(', ')
|
|
358
|
+
|
|
359
|
+
@writer.data_element('x:Anchor', data)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
#
|
|
363
|
+
# Write the <x:AutoFill> element.
|
|
364
|
+
#
|
|
365
|
+
def write_auto_fill
|
|
366
|
+
data = 'False'
|
|
367
|
+
|
|
368
|
+
@writer.data_element('x:AutoFill', data)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
#
|
|
372
|
+
# Write the <x:Row> element.
|
|
373
|
+
#
|
|
374
|
+
def write_row(data)
|
|
375
|
+
@writer.data_element('x:Row', data)
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
#
|
|
379
|
+
# Write the <x:Column> element.
|
|
380
|
+
#
|
|
381
|
+
def write_column(data)
|
|
382
|
+
@writer.data_element('x:Column', data)
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
#
|
|
3
|
+
# XMLWriterSimple
|
|
4
|
+
#
|
|
5
|
+
require 'stringio'
|
|
6
|
+
|
|
7
|
+
module Writexlsx
|
|
8
|
+
module Package
|
|
9
|
+
class XMLWriterSimple
|
|
10
|
+
def initialize
|
|
11
|
+
@io = StringIO.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_xml_writer(filename = nil)
|
|
15
|
+
fh = File.open(filename, "wb")
|
|
16
|
+
|
|
17
|
+
@io = fh
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def xml_decl(encoding = 'UTF-8', standalone = true)
|
|
21
|
+
str = %Q!<?xml version="1.0" encoding="#{encoding}" standalone="#{standalone ? 'yes' : 'no'}"?>\n!
|
|
22
|
+
io_write(str)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def start_tag(tag, attr = [])
|
|
26
|
+
str = "<#{tag}#{key_vals(attr)}>"
|
|
27
|
+
io_write(str)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def end_tag(tag)
|
|
31
|
+
str = "</#{tag}>"
|
|
32
|
+
io_write(str)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def empty_tag(tag, attr = [])
|
|
36
|
+
str = "<#{tag}#{key_vals(attr)} />"
|
|
37
|
+
io_write(str)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def data_element(tag, data, attr = [])
|
|
41
|
+
str = start_tag(tag, attr)
|
|
42
|
+
str << io_write("#{characters(data)}")
|
|
43
|
+
str << end_tag(tag)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def characters(data)
|
|
47
|
+
escape_xml_chars(data)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def crlf
|
|
51
|
+
io_write("\n")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def close
|
|
55
|
+
@io.close
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def string
|
|
59
|
+
@io.string
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def io_write(str)
|
|
63
|
+
@io << str
|
|
64
|
+
str
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def key_val(key, val)
|
|
70
|
+
%Q{ #{key}="#{val}"}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def key_vals(attr)
|
|
74
|
+
array = []
|
|
75
|
+
(0 .. attr.size-1).step(2) do |i|
|
|
76
|
+
array << key_val(attr[i], escape_xml_chars(attr[i+1]))
|
|
77
|
+
end
|
|
78
|
+
array.join('')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def escape_xml_chars(str = '')
|
|
82
|
+
if str =~ /[&<>"]/
|
|
83
|
+
str.gsub(/&/, '&').gsub(/</, '<').gsub(/>/, '>').gsub(/"/, '"')
|
|
84
|
+
else
|
|
85
|
+
str
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|