caxlsx 2.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.
- checksums.yaml +7 -0
- data/.yardopts +9 -0
- data/.yardopts_guide +19 -0
- data/CHANGELOG.md +239 -0
- data/LICENSE +22 -0
- data/README.md +256 -0
- data/Rakefile +31 -0
- data/examples/2010_comments.rb +17 -0
- data/examples/anchor_swapping.rb +28 -0
- data/examples/auto_filter.rb +16 -0
- data/examples/basic_charts.rb +58 -0
- data/examples/chart_colors.rb +88 -0
- data/examples/colored_links.rb +59 -0
- data/examples/conditional_formatting/example_conditional_formatting.rb +74 -0
- data/examples/conditional_formatting/getting_barred.rb +37 -0
- data/examples/conditional_formatting/hitting_the_high_notes.rb +37 -0
- data/examples/conditional_formatting/scaled_colors.rb +39 -0
- data/examples/conditional_formatting/stop_and_go.rb +37 -0
- data/examples/data_validation.rb +50 -0
- data/examples/example.rb +777 -0
- data/examples/extractive.rb +45 -0
- data/examples/image1.jpeg +0 -0
- data/examples/ios_preview.rb +14 -0
- data/examples/page_setup.rb +11 -0
- data/examples/pivot_table.rb +39 -0
- data/examples/sheet_protection.rb +10 -0
- data/examples/skydrive/real_example.rb +63 -0
- data/examples/styles.rb +66 -0
- data/examples/underline.rb +13 -0
- data/examples/wrap_text.rb +21 -0
- data/lib/axlsx.rb +152 -0
- data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
- data/lib/axlsx/content_type/content_type.rb +26 -0
- data/lib/axlsx/content_type/default.rb +25 -0
- data/lib/axlsx/content_type/override.rb +25 -0
- data/lib/axlsx/doc_props/app.rb +235 -0
- data/lib/axlsx/doc_props/core.rb +39 -0
- data/lib/axlsx/drawing/ax_data_source.rb +26 -0
- data/lib/axlsx/drawing/axes.rb +61 -0
- data/lib/axlsx/drawing/axis.rb +187 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +151 -0
- data/lib/axlsx/drawing/bar_series.rb +82 -0
- data/lib/axlsx/drawing/cat_axis.rb +85 -0
- data/lib/axlsx/drawing/chart.rb +232 -0
- data/lib/axlsx/drawing/d_lbls.rb +90 -0
- data/lib/axlsx/drawing/drawing.rb +162 -0
- data/lib/axlsx/drawing/graphic_frame.rb +54 -0
- data/lib/axlsx/drawing/hyperlink.rb +102 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +68 -0
- data/lib/axlsx/drawing/line_chart.rb +99 -0
- data/lib/axlsx/drawing/line_series.rb +81 -0
- data/lib/axlsx/drawing/marker.rb +84 -0
- data/lib/axlsx/drawing/num_data.rb +52 -0
- data/lib/axlsx/drawing/num_data_source.rb +62 -0
- data/lib/axlsx/drawing/num_val.rb +32 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +98 -0
- data/lib/axlsx/drawing/pic.rb +205 -0
- data/lib/axlsx/drawing/picture_locking.rb +44 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +48 -0
- data/lib/axlsx/drawing/pie_series.rb +74 -0
- data/lib/axlsx/drawing/scaling.rb +60 -0
- data/lib/axlsx/drawing/scatter_chart.rb +74 -0
- data/lib/axlsx/drawing/scatter_series.rb +65 -0
- data/lib/axlsx/drawing/ser_axis.rb +45 -0
- data/lib/axlsx/drawing/series.rb +69 -0
- data/lib/axlsx/drawing/series_title.rb +23 -0
- data/lib/axlsx/drawing/str_data.rb +42 -0
- data/lib/axlsx/drawing/str_val.rb +32 -0
- data/lib/axlsx/drawing/title.rb +78 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb +92 -0
- data/lib/axlsx/drawing/val_axis.rb +37 -0
- data/lib/axlsx/drawing/view_3D.rb +115 -0
- data/lib/axlsx/drawing/vml_drawing.rb +42 -0
- data/lib/axlsx/drawing/vml_shape.rb +66 -0
- data/lib/axlsx/package.rb +352 -0
- data/lib/axlsx/rels/relationship.rb +129 -0
- data/lib/axlsx/rels/relationships.rb +29 -0
- data/lib/axlsx/stylesheet/border.rb +71 -0
- data/lib/axlsx/stylesheet/border_pr.rb +71 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb +134 -0
- data/lib/axlsx/stylesheet/cell_protection.rb +43 -0
- data/lib/axlsx/stylesheet/cell_style.rb +74 -0
- data/lib/axlsx/stylesheet/color.rb +78 -0
- data/lib/axlsx/stylesheet/dxf.rb +79 -0
- data/lib/axlsx/stylesheet/fill.rb +35 -0
- data/lib/axlsx/stylesheet/font.rb +148 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb +103 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb +37 -0
- data/lib/axlsx/stylesheet/num_fmt.rb +79 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb +73 -0
- data/lib/axlsx/stylesheet/styles.rb +420 -0
- data/lib/axlsx/stylesheet/table_style.rb +54 -0
- data/lib/axlsx/stylesheet/table_style_element.rb +79 -0
- data/lib/axlsx/stylesheet/table_styles.rb +46 -0
- data/lib/axlsx/stylesheet/xf.rb +147 -0
- data/lib/axlsx/util/accessors.rb +64 -0
- data/lib/axlsx/util/constants.rb +392 -0
- data/lib/axlsx/util/options_parser.rb +15 -0
- data/lib/axlsx/util/parser.rb +44 -0
- data/lib/axlsx/util/serialized_attributes.rb +79 -0
- data/lib/axlsx/util/simple_typed_list.rb +203 -0
- data/lib/axlsx/util/storage.rb +146 -0
- data/lib/axlsx/util/validators.rb +300 -0
- data/lib/axlsx/version.rb +5 -0
- data/lib/axlsx/workbook/defined_name.rb +129 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/shared_strings_table.rb +77 -0
- data/lib/axlsx/workbook/workbook.rb +354 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +94 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +246 -0
- data/lib/axlsx/workbook/worksheet/break.rb +37 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +416 -0
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +144 -0
- data/lib/axlsx/workbook/worksheet/cfvo.rb +62 -0
- data/lib/axlsx/workbook/worksheet/cfvos.rb +15 -0
- data/lib/axlsx/workbook/worksheet/col.rb +144 -0
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +35 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb +110 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +92 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +82 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +220 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_bar.rb +131 -0
- data/lib/axlsx/workbook/worksheet/data_validation.rb +244 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +30 -0
- data/lib/axlsx/workbook/worksheet/dimension.rb +64 -0
- data/lib/axlsx/workbook/worksheet/header_footer.rb +54 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb +83 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +99 -0
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +44 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +242 -0
- data/lib/axlsx/workbook/worksheet/pane.rb +141 -0
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +273 -0
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +66 -0
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +24 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +41 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +49 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +172 -0
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +33 -0
- data/lib/axlsx/workbook/worksheet/selection.rb +103 -0
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +29 -0
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +60 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +69 -0
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +120 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +213 -0
- data/lib/axlsx/workbook/worksheet/table.rb +102 -0
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +51 -0
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +769 -0
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +58 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +58 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +74 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
- data/lib/schema/dc.xsd +118 -0
- data/lib/schema/dcmitype.xsd +52 -0
- data/lib/schema/dcterms.xsd +331 -0
- data/lib/schema/dml-chart.xsd +1499 -0
- data/lib/schema/dml-chartDrawing.xsd +146 -0
- data/lib/schema/dml-compatibility.xsd +14 -0
- data/lib/schema/dml-diagram.xsd +1091 -0
- data/lib/schema/dml-lockedCanvas.xsd +11 -0
- data/lib/schema/dml-main.xsd +3048 -0
- data/lib/schema/dml-picture.xsd +23 -0
- data/lib/schema/dml-spreadsheetDrawing.xsd +185 -0
- data/lib/schema/dml-wordprocessingDrawing.xsd +185 -0
- data/lib/schema/opc-contentTypes.xsd +42 -0
- data/lib/schema/opc-coreProperties.xsd +54 -0
- data/lib/schema/opc-digSig.xsd +49 -0
- data/lib/schema/opc-relationships.xsd +33 -0
- data/lib/schema/pml.xsd +1676 -0
- data/lib/schema/shared-additionalCharacteristics.xsd +28 -0
- data/lib/schema/shared-bibliography.xsd +144 -0
- data/lib/schema/shared-commonSimpleTypes.xsd +166 -0
- data/lib/schema/shared-customXmlDataProperties.xsd +25 -0
- data/lib/schema/shared-customXmlSchemaProperties.xsd +18 -0
- data/lib/schema/shared-documentPropertiesCustom.xsd +59 -0
- data/lib/schema/shared-documentPropertiesExtended.xsd +56 -0
- data/lib/schema/shared-documentPropertiesVariantTypes.xsd +195 -0
- data/lib/schema/shared-math.xsd +582 -0
- data/lib/schema/shared-relationshipReference.xsd +25 -0
- data/lib/schema/sml.xsd +4434 -0
- data/lib/schema/vml-main.xsd +569 -0
- data/lib/schema/vml-officeDrawing.xsd +509 -0
- data/lib/schema/vml-presentationDrawing.xsd +12 -0
- data/lib/schema/vml-spreadsheetDrawing.xsd +108 -0
- data/lib/schema/vml-wordprocessingDrawing.xsd +96 -0
- data/lib/schema/wml.xsd +3644 -0
- data/lib/schema/xml.xsd +116 -0
- data/test/benchmark.rb +72 -0
- data/test/content_type/tc_content_type.rb +76 -0
- data/test/content_type/tc_default.rb +16 -0
- data/test/content_type/tc_override.rb +14 -0
- data/test/doc_props/tc_app.rb +43 -0
- data/test/doc_props/tc_core.rb +42 -0
- data/test/drawing/tc_axes.rb +8 -0
- data/test/drawing/tc_axis.rb +85 -0
- data/test/drawing/tc_bar_3D_chart.rb +71 -0
- data/test/drawing/tc_bar_series.rb +37 -0
- data/test/drawing/tc_cat_axis.rb +31 -0
- data/test/drawing/tc_cat_axis_data.rb +27 -0
- data/test/drawing/tc_chart.rb +110 -0
- data/test/drawing/tc_d_lbls.rb +57 -0
- data/test/drawing/tc_data_source.rb +17 -0
- data/test/drawing/tc_drawing.rb +80 -0
- data/test/drawing/tc_graphic_frame.rb +27 -0
- data/test/drawing/tc_hyperlink.rb +64 -0
- data/test/drawing/tc_line_3d_chart.rb +47 -0
- data/test/drawing/tc_line_chart.rb +39 -0
- data/test/drawing/tc_line_series.rb +30 -0
- data/test/drawing/tc_marker.rb +44 -0
- data/test/drawing/tc_named_axis_data.rb +27 -0
- data/test/drawing/tc_num_data.rb +31 -0
- data/test/drawing/tc_num_val.rb +29 -0
- data/test/drawing/tc_one_cell_anchor.rb +66 -0
- data/test/drawing/tc_pic.rb +107 -0
- data/test/drawing/tc_picture_locking.rb +72 -0
- data/test/drawing/tc_pie_3D_chart.rb +28 -0
- data/test/drawing/tc_pie_series.rb +32 -0
- data/test/drawing/tc_scaling.rb +36 -0
- data/test/drawing/tc_scatter_chart.rb +48 -0
- data/test/drawing/tc_scatter_series.rb +21 -0
- data/test/drawing/tc_ser_axis.rb +31 -0
- data/test/drawing/tc_series.rb +23 -0
- data/test/drawing/tc_series_title.rb +33 -0
- data/test/drawing/tc_str_data.rb +18 -0
- data/test/drawing/tc_str_val.rb +21 -0
- data/test/drawing/tc_title.rb +49 -0
- data/test/drawing/tc_two_cell_anchor.rb +36 -0
- data/test/drawing/tc_val_axis.rb +24 -0
- data/test/drawing/tc_view_3D.rb +54 -0
- data/test/drawing/tc_vml_drawing.rb +25 -0
- data/test/drawing/tc_vml_shape.rb +106 -0
- data/test/profile.rb +24 -0
- data/test/rels/tc_relationship.rb +44 -0
- data/test/rels/tc_relationships.rb +37 -0
- data/test/stylesheet/tc_border.rb +37 -0
- data/test/stylesheet/tc_border_pr.rb +32 -0
- data/test/stylesheet/tc_cell_alignment.rb +81 -0
- data/test/stylesheet/tc_cell_protection.rb +29 -0
- data/test/stylesheet/tc_cell_style.rb +57 -0
- data/test/stylesheet/tc_color.rb +43 -0
- data/test/stylesheet/tc_dxf.rb +81 -0
- data/test/stylesheet/tc_fill.rb +18 -0
- data/test/stylesheet/tc_font.rb +121 -0
- data/test/stylesheet/tc_gradient_fill.rb +72 -0
- data/test/stylesheet/tc_gradient_stop.rb +31 -0
- data/test/stylesheet/tc_num_fmt.rb +30 -0
- data/test/stylesheet/tc_pattern_fill.rb +43 -0
- data/test/stylesheet/tc_styles.rb +235 -0
- data/test/stylesheet/tc_table_style.rb +44 -0
- data/test/stylesheet/tc_table_style_element.rb +45 -0
- data/test/stylesheet/tc_table_styles.rb +29 -0
- data/test/stylesheet/tc_xf.rb +120 -0
- data/test/tc_axlsx.rb +72 -0
- data/test/tc_helper.rb +10 -0
- data/test/tc_package.rb +227 -0
- data/test/util/tc_serialized_attributes.rb +19 -0
- data/test/util/tc_simple_typed_list.rb +78 -0
- data/test/util/tc_validators.rb +186 -0
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_shared_strings_table.rb +44 -0
- data/test/workbook/tc_workbook.rb +125 -0
- data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
- data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
- data/test/workbook/worksheet/tc_break.rb +49 -0
- data/test/workbook/worksheet/tc_cell.rb +319 -0
- data/test/workbook/worksheet/tc_cfvo.rb +31 -0
- data/test/workbook/worksheet/tc_col.rb +78 -0
- data/test/workbook/worksheet/tc_color_scale.rb +58 -0
- data/test/workbook/worksheet/tc_comment.rb +72 -0
- data/test/workbook/worksheet/tc_comments.rb +57 -0
- data/test/workbook/worksheet/tc_conditional_formatting.rb +224 -0
- data/test/workbook/worksheet/tc_data_bar.rb +46 -0
- data/test/workbook/worksheet/tc_data_validation.rb +265 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +124 -0
- data/test/workbook/worksheet/tc_header_footer.rb +151 -0
- data/test/workbook/worksheet/tc_icon_set.rb +45 -0
- data/test/workbook/worksheet/tc_page_margins.rb +97 -0
- data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
- data/test/workbook/worksheet/tc_page_setup.rb +143 -0
- data/test/workbook/worksheet/tc_pane.rb +54 -0
- data/test/workbook/worksheet/tc_pivot_table.rb +120 -0
- data/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +54 -0
- data/test/workbook/worksheet/tc_print_options.rb +72 -0
- data/test/workbook/worksheet/tc_protected_range.rb +17 -0
- data/test/workbook/worksheet/tc_row.rb +117 -0
- data/test/workbook/worksheet/tc_selection.rb +55 -0
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +88 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
- data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/tc_table.rb +68 -0
- data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
- data/test/workbook/worksheet/tc_worksheet.rb +538 -0
- data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +55 -0
- metadata +546 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
# A PatternFill is the pattern and solid fill styling for a cell.
|
|
4
|
+
# @note The recommended way to manage styles is with Styles#add_style
|
|
5
|
+
# @see Style#add_style
|
|
6
|
+
class PatternFill
|
|
7
|
+
|
|
8
|
+
include Axlsx::OptionsParser
|
|
9
|
+
# Creates a new PatternFill Object
|
|
10
|
+
# @option options [Symbol] patternType
|
|
11
|
+
# @option options [Color] fgColor
|
|
12
|
+
# @option options [Color] bgColor
|
|
13
|
+
def initialize(options={})
|
|
14
|
+
@patternType = :none
|
|
15
|
+
parse_options options
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The color to use for the the background in solid fills.
|
|
19
|
+
# @return [Color]
|
|
20
|
+
attr_reader :fgColor
|
|
21
|
+
|
|
22
|
+
# The color to use for the background of the fill when the type is not solid.
|
|
23
|
+
# @return [Color]
|
|
24
|
+
attr_reader :bgColor
|
|
25
|
+
|
|
26
|
+
# The pattern type to use
|
|
27
|
+
# @note
|
|
28
|
+
# patternType must be one of
|
|
29
|
+
# :none
|
|
30
|
+
# :solid
|
|
31
|
+
# :mediumGray
|
|
32
|
+
# :darkGray
|
|
33
|
+
# :lightGray
|
|
34
|
+
# :darkHorizontal
|
|
35
|
+
# :darkVertical
|
|
36
|
+
# :darkDown
|
|
37
|
+
# :darkUp
|
|
38
|
+
# :darkGrid
|
|
39
|
+
# :darkTrellis
|
|
40
|
+
# :lightHorizontal
|
|
41
|
+
# :lightVertical
|
|
42
|
+
# :lightDown
|
|
43
|
+
# :lightUp
|
|
44
|
+
# :lightGrid
|
|
45
|
+
# :lightTrellis
|
|
46
|
+
# :gray125
|
|
47
|
+
# :gray0625
|
|
48
|
+
# @see Office Open XML Part 1 18.18.55
|
|
49
|
+
attr_reader :patternType
|
|
50
|
+
|
|
51
|
+
# @see fgColor
|
|
52
|
+
def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor=v end
|
|
53
|
+
# @see bgColor
|
|
54
|
+
def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor=v end
|
|
55
|
+
# @see patternType
|
|
56
|
+
def patternType=(v) Axlsx::validate_pattern_type v; @patternType = v end
|
|
57
|
+
|
|
58
|
+
# Serializes the object
|
|
59
|
+
# @param [String] str
|
|
60
|
+
# @return [String]
|
|
61
|
+
def to_xml_string(str = '')
|
|
62
|
+
str << '<patternFill patternType="' << patternType.to_s << '">'
|
|
63
|
+
if fgColor.is_a?(Color)
|
|
64
|
+
fgColor.to_xml_string str, "fgColor"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if bgColor.is_a?(Color)
|
|
68
|
+
bgColor.to_xml_string str, "bgColor"
|
|
69
|
+
end
|
|
70
|
+
str << '</patternFill>'
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
require 'axlsx/stylesheet/border.rb'
|
|
4
|
+
require 'axlsx/stylesheet/border_pr.rb'
|
|
5
|
+
require 'axlsx/stylesheet/cell_alignment.rb'
|
|
6
|
+
require 'axlsx/stylesheet/cell_style.rb'
|
|
7
|
+
require 'axlsx/stylesheet/color.rb'
|
|
8
|
+
require 'axlsx/stylesheet/fill.rb'
|
|
9
|
+
require 'axlsx/stylesheet/font.rb'
|
|
10
|
+
require 'axlsx/stylesheet/gradient_fill.rb'
|
|
11
|
+
require 'axlsx/stylesheet/gradient_stop.rb'
|
|
12
|
+
require 'axlsx/stylesheet/num_fmt.rb'
|
|
13
|
+
require 'axlsx/stylesheet/pattern_fill.rb'
|
|
14
|
+
require 'axlsx/stylesheet/table_style.rb'
|
|
15
|
+
require 'axlsx/stylesheet/table_styles.rb'
|
|
16
|
+
require 'axlsx/stylesheet/table_style_element.rb'
|
|
17
|
+
require 'axlsx/stylesheet/dxf.rb'
|
|
18
|
+
require 'axlsx/stylesheet/xf.rb'
|
|
19
|
+
require 'axlsx/stylesheet/cell_protection.rb'
|
|
20
|
+
|
|
21
|
+
#The Styles class manages worksheet styles
|
|
22
|
+
# In addition to creating the require style objects for a valid xlsx package, this class provides the key mechanism for adding styles to your workbook, and safely applying them to the cells of your worksheet.
|
|
23
|
+
# All portions of the stylesheet are implemented here exception colors, which specify legacy and modified pallete colors, and exLst, whic is used as a future feature data storage area.
|
|
24
|
+
# @see Office Open XML Part 1 18.8.11 for gory details on how this stuff gets put together
|
|
25
|
+
# @see Styles#add_style
|
|
26
|
+
# @note The recommended way to manage styles is with add_style
|
|
27
|
+
class Styles
|
|
28
|
+
# numFmts for your styles.
|
|
29
|
+
# The default styles, which change based on the system local, are as follows.
|
|
30
|
+
# id formatCode
|
|
31
|
+
# 0 General
|
|
32
|
+
# 1 0
|
|
33
|
+
# 2 0.00
|
|
34
|
+
# 3 #,##0
|
|
35
|
+
# 4 #,##0.00
|
|
36
|
+
# 9 0%
|
|
37
|
+
# 10 0.00%
|
|
38
|
+
# 11 0.00E+00
|
|
39
|
+
# 12 # ?/?
|
|
40
|
+
# 13 # ??/??
|
|
41
|
+
# 14 mm-dd-yy
|
|
42
|
+
# 15 d-mmm-yy
|
|
43
|
+
# 16 d-mmm
|
|
44
|
+
# 17 mmm-yy
|
|
45
|
+
# 18 h:mm AM/PM
|
|
46
|
+
# 19 h:mm:ss AM/PM
|
|
47
|
+
# 20 h:mm
|
|
48
|
+
# 21 h:mm:ss
|
|
49
|
+
# 22 m/d/yy h:mm
|
|
50
|
+
# 37 #,##0 ;(#,##0)
|
|
51
|
+
# 38 #,##0 ;[Red](#,##0)
|
|
52
|
+
# 39 #,##0.00;(#,##0.00)
|
|
53
|
+
# 40 #,##0.00;[Red](#,##0.00)
|
|
54
|
+
# 45 mm:ss
|
|
55
|
+
# 46 [h]:mm:ss
|
|
56
|
+
# 47 mmss.0
|
|
57
|
+
# 48 ##0.0E+0
|
|
58
|
+
# 49 @
|
|
59
|
+
# Axlsx also defines the following constants which you can use in add_style.
|
|
60
|
+
# NUM_FMT_PERCENT formats to "0%"
|
|
61
|
+
# NUM_FMT_YYYYMMDD formats to "yyyy/mm/dd"
|
|
62
|
+
# NUM_FMT_YYYYMMDDHHMMSS formats to "yyyy/mm/dd hh:mm:ss"
|
|
63
|
+
# @see Office Open XML Part 1 - 18.8.31 for more information on creating number formats
|
|
64
|
+
# @return [SimpleTypedList]
|
|
65
|
+
# @note The recommended way to manage styles is with add_style
|
|
66
|
+
# @see Styles#add_style
|
|
67
|
+
attr_reader :numFmts
|
|
68
|
+
|
|
69
|
+
# The collection of fonts used in this workbook
|
|
70
|
+
# @return [SimpleTypedList]
|
|
71
|
+
# @note The recommended way to manage styles is with add_style
|
|
72
|
+
# @see Styles#add_style
|
|
73
|
+
attr_reader :fonts
|
|
74
|
+
|
|
75
|
+
# The collection of fills used in this workbook
|
|
76
|
+
# @return [SimpleTypedList]
|
|
77
|
+
# @note The recommended way to manage styles is with add_style
|
|
78
|
+
# @see Styles#add_style
|
|
79
|
+
attr_reader :fills
|
|
80
|
+
|
|
81
|
+
# The collection of borders used in this workbook
|
|
82
|
+
# Axlsx predefines THIN_BORDER which can be used to put a border around all of your cells.
|
|
83
|
+
# @return [SimpleTypedList]
|
|
84
|
+
# @note The recommended way to manage styles is with add_style
|
|
85
|
+
# @see Styles#add_style
|
|
86
|
+
attr_reader :borders
|
|
87
|
+
|
|
88
|
+
# The collection of master formatting records for named cell styles, which means records defined in cellStyles, in the workbook
|
|
89
|
+
# @return [SimpleTypedList]
|
|
90
|
+
# @note The recommended way to manage styles is with add_style
|
|
91
|
+
# @see Styles#add_style
|
|
92
|
+
attr_reader :cellStyleXfs
|
|
93
|
+
|
|
94
|
+
# The collection of named styles, referencing cellStyleXfs items in the workbook.
|
|
95
|
+
# @return [SimpleTypedList]
|
|
96
|
+
# @note The recommended way to manage styles is with add_style
|
|
97
|
+
# @see Styles#add_style
|
|
98
|
+
attr_reader :cellStyles
|
|
99
|
+
|
|
100
|
+
# The collection of master formatting records. This is the list that you will actually use in styling a workbook.
|
|
101
|
+
# @return [SimpleTypedList]
|
|
102
|
+
# @note The recommended way to manage styles is with add_style
|
|
103
|
+
# @see Styles#add_style
|
|
104
|
+
attr_reader :cellXfs
|
|
105
|
+
|
|
106
|
+
# The collection of non-cell formatting records used in the worksheet.
|
|
107
|
+
# @return [SimpleTypedList]
|
|
108
|
+
# @note The recommended way to manage styles is with add_style
|
|
109
|
+
# @see Styles#add_style
|
|
110
|
+
attr_reader :dxfs
|
|
111
|
+
|
|
112
|
+
# The collection of table styles that will be available to the user in the excel UI
|
|
113
|
+
# @return [SimpleTypedList]
|
|
114
|
+
# @note The recommended way to manage styles is with add_style
|
|
115
|
+
# @see Styles#add_style
|
|
116
|
+
attr_reader :tableStyles
|
|
117
|
+
|
|
118
|
+
# Creates a new Styles object and prepopulates it with the requires objects to generate a valid package style part.
|
|
119
|
+
def initialize()
|
|
120
|
+
load_default_styles
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Drastically simplifies style creation and management.
|
|
124
|
+
# @return [Integer]
|
|
125
|
+
# @option options [String] fg_color The text color
|
|
126
|
+
# @option options [Integer] sz The text size
|
|
127
|
+
# @option options [Boolean] b Indicates if the text should be bold
|
|
128
|
+
# @option options [Boolean] i Indicates if the text should be italicised
|
|
129
|
+
# @option options [Boolean] u Indicates if the text should be underlined
|
|
130
|
+
# @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough
|
|
131
|
+
# @option options [Boolean] strike Indicates if the text should be rendered with a shadow
|
|
132
|
+
# @option options [Integer] charset The character set to use.
|
|
133
|
+
# @option options [Integer] family The font family to use.
|
|
134
|
+
# @option options [String] font_name The name of the font to use
|
|
135
|
+
# @option options [Integer] num_fmt The number format to apply
|
|
136
|
+
# @option options [String] format_code The formatting to apply.
|
|
137
|
+
# @option options [Integer|Hash] border The border style to use.
|
|
138
|
+
# borders support style, color and edges options @see parse_border_options
|
|
139
|
+
# @option options [String] bg_color The background color to apply to the cell
|
|
140
|
+
# @option options [Boolean] hidden Indicates if the cell should be hidden
|
|
141
|
+
# @option options [Boolean] locked Indicates if the cell should be locked
|
|
142
|
+
# @option options [Symbol] type What type of style is this. Options are [:dxf, :xf]. :xf is default
|
|
143
|
+
# @option options [Hash] alignment A hash defining any of the attributes used in CellAlignment
|
|
144
|
+
# @see CellAlignment
|
|
145
|
+
#
|
|
146
|
+
# @example You Got Style
|
|
147
|
+
# require "rubygems" # if that is your preferred way to manage gems!
|
|
148
|
+
# require "axlsx"
|
|
149
|
+
#
|
|
150
|
+
# p = Axlsx::Package.new
|
|
151
|
+
# ws = p.workbook.add_worksheet
|
|
152
|
+
#
|
|
153
|
+
# # black text on a white background at 14pt with thin borders!
|
|
154
|
+
# title = ws.style.add_style(:bg_color => "FFFF0000", :fg_color=>"#FF000000", :sz=>14, :border=> {:style => :thin, :color => "FFFF0000"}
|
|
155
|
+
#
|
|
156
|
+
# ws.add_row ["Least Popular Pets"]
|
|
157
|
+
# ws.add_row ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"], :style=>title
|
|
158
|
+
# ws.add_row ["Votes", 6, 4, 1], :style=>Axlsx::STYLE_THIN_BORDER
|
|
159
|
+
# f = File.open('example_you_got_style.xlsx', 'w')
|
|
160
|
+
# p.serialize(f)
|
|
161
|
+
#
|
|
162
|
+
# @example Styling specifically
|
|
163
|
+
# # an example of applying specific styles to specific cells
|
|
164
|
+
# require "rubygems" # if that is your preferred way to manage gems!
|
|
165
|
+
# require "axlsx"
|
|
166
|
+
#
|
|
167
|
+
# p = Axlsx::Package.new
|
|
168
|
+
# ws = p.workbook.add_worksheet
|
|
169
|
+
#
|
|
170
|
+
# # define your styles
|
|
171
|
+
# title = ws.style.add_style(:bg_color => "FFFF0000",
|
|
172
|
+
# :fg_color=>"#FF000000",
|
|
173
|
+
# :border=>Axlsx::STYLE_THIN_BORDER,
|
|
174
|
+
# :alignment=>{:horizontal => :center})
|
|
175
|
+
#
|
|
176
|
+
# date_time = ws.style.add_style(:num_fmt => Axlsx::NUM_FMT_YYYYMMDDHHMMSS,
|
|
177
|
+
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
178
|
+
#
|
|
179
|
+
# percent = ws.style.add_style(:num_fmt => Axlsx::NUM_FMT_PERCENT,
|
|
180
|
+
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
181
|
+
#
|
|
182
|
+
# currency = ws.style.add_style(:format_code=>"¥#,##0;[Red]¥-#,##0",
|
|
183
|
+
# :border=>Axlsx::STYLE_THIN_BORDER)
|
|
184
|
+
#
|
|
185
|
+
# # build your rows
|
|
186
|
+
# ws.add_row ["Generated At:", Time.now], :styles=>[nil, date_time]
|
|
187
|
+
# ws.add_row ["Previous Year Quarterly Profits (JPY)"], :style=>title
|
|
188
|
+
# ws.add_row ["Quarter", "Profit", "% of Total"], :style=>title
|
|
189
|
+
# ws.add_row ["Q1", 4000, 40], :style=>[title, currency, percent]
|
|
190
|
+
# ws.add_row ["Q2", 3000, 30], :style=>[title, currency, percent]
|
|
191
|
+
# ws.add_row ["Q3", 1000, 10], :style=>[title, currency, percent]
|
|
192
|
+
# ws.add_row ["Q4", 2000, 20], :style=>[title, currency, percent]
|
|
193
|
+
# f = File.open('example_you_got_style.xlsx', 'w')
|
|
194
|
+
# p.serialize(f)
|
|
195
|
+
#
|
|
196
|
+
# @example Differential styling
|
|
197
|
+
# # Differential styles apply on top of cell styles. Used in Conditional Formatting. Must specify :type => :dxf, and you can't use :num_fmt.
|
|
198
|
+
# require "rubygems" # if that is your preferred way to manage gems!
|
|
199
|
+
# require "axlsx"
|
|
200
|
+
#
|
|
201
|
+
# p = Axlsx::Package.new
|
|
202
|
+
# wb = p.workbook
|
|
203
|
+
# ws = wb.add_worksheet
|
|
204
|
+
#
|
|
205
|
+
# # define your styles
|
|
206
|
+
# profitable = wb.styles.add_style(:bg_color => "FFFF0000",
|
|
207
|
+
# :fg_color=>"#FF000000",
|
|
208
|
+
# :type => :dxf)
|
|
209
|
+
#
|
|
210
|
+
# ws.add_row ["Genreated At:", Time.now], :styles=>[nil, date_time]
|
|
211
|
+
# ws.add_row ["Previous Year Quarterly Profits (JPY)"], :style=>title
|
|
212
|
+
# ws.add_row ["Quarter", "Profit", "% of Total"], :style=>title
|
|
213
|
+
# ws.add_row ["Q1", 4000, 40], :style=>[title, currency, percent]
|
|
214
|
+
# ws.add_row ["Q2", 3000, 30], :style=>[title, currency, percent]
|
|
215
|
+
# ws.add_row ["Q3", 1000, 10], :style=>[title, currency, percent]
|
|
216
|
+
# ws.add_row ["Q4", 2000, 20], :style=>[title, currency, percent]
|
|
217
|
+
#
|
|
218
|
+
# ws.add_conditional_formatting("A1:A7", { :type => :cellIs, :operator => :greaterThan, :formula => "2000", :dxfId => profitable, :priority => 1 })
|
|
219
|
+
# f = File.open('example_differential_styling', 'w')
|
|
220
|
+
# p.serialize(f)
|
|
221
|
+
#
|
|
222
|
+
def add_style(options={})
|
|
223
|
+
# Default to :xf
|
|
224
|
+
options[:type] ||= :xf
|
|
225
|
+
raise ArgumentError, "Type must be one of [:xf, :dxf]" unless [:xf, :dxf].include?(options[:type] )
|
|
226
|
+
|
|
227
|
+
fill = parse_fill_options options
|
|
228
|
+
font = parse_font_options options
|
|
229
|
+
numFmt = parse_num_fmt_options options
|
|
230
|
+
border = parse_border_options options
|
|
231
|
+
alignment = parse_alignment_options options
|
|
232
|
+
protection = parse_protection_options options
|
|
233
|
+
|
|
234
|
+
case options[:type]
|
|
235
|
+
when :dxf
|
|
236
|
+
style = Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
|
|
237
|
+
else
|
|
238
|
+
style = Xf.new :fillId=>fill || 0, :fontId=>font || 0, :numFmtId=>numFmt || 0, :borderId=>border || 0, :alignment => alignment, :protection => protection, :applyFill=>!fill.nil?, :applyFont=>!font.nil?, :applyNumberFormat =>!numFmt.nil?, :applyBorder=>!border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
options[:type] == :xf ? cellXfs << style : dxfs << style
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# parses add_style options for protection styles
|
|
245
|
+
# noop if options hash does not include :hide or :locked key
|
|
246
|
+
|
|
247
|
+
# @option options [Boolean] hide boolean value defining cell protection attribute for hiding.
|
|
248
|
+
# @option options [Boolean] locked boolean value defining cell protection attribute for locking.
|
|
249
|
+
# @return [CellProtection]
|
|
250
|
+
def parse_protection_options(options={})
|
|
251
|
+
return if (options.keys & [:hidden, :locked]).empty?
|
|
252
|
+
CellProtection.new(options)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# parses add_style options for alignment
|
|
256
|
+
# noop if options hash does not include :alignment key
|
|
257
|
+
# @option options [Hash] alignment A hash of options to prive the CellAlignment intializer
|
|
258
|
+
# @return [CellAlignment]
|
|
259
|
+
# @see CellAlignment
|
|
260
|
+
def parse_alignment_options(options={})
|
|
261
|
+
return unless options[:alignment]
|
|
262
|
+
CellAlignment.new options[:alignment]
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# parses add_style options for fonts. If the options hash contains :type => :dxf we return a new Font object.
|
|
266
|
+
# if not, we return the index of the newly created font object in the styles.fonts collection.
|
|
267
|
+
# @note noop if none of the options described here are set on the options parameter.
|
|
268
|
+
# @option options [Symbol] type The type of style object we are working with (dxf or xf)
|
|
269
|
+
# @option options [String] fg_color The text color
|
|
270
|
+
# @option options [Integer] sz The text size
|
|
271
|
+
# @option options [Boolean] b Indicates if the text should be bold
|
|
272
|
+
# @option options [Boolean] i Indicates if the text should be italicised
|
|
273
|
+
# @option options [Boolean] u Indicates if the text should be underlined
|
|
274
|
+
# @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough
|
|
275
|
+
# @option options [Boolean] outline Indicates if the text should be rendered with a shadow
|
|
276
|
+
# @option options [Integer] charset The character set to use.
|
|
277
|
+
# @option options [Integer] family The font family to use.
|
|
278
|
+
# @option options [String] font_name The name of the font to use
|
|
279
|
+
# @return [Font|Integer]
|
|
280
|
+
def parse_font_options(options={})
|
|
281
|
+
return if (options.keys & [:fg_color, :sz, :b, :i, :u, :strike, :outline, :shadow, :charset, :family, :font_name]).empty?
|
|
282
|
+
fonts.first.instance_values.each do |key, value|
|
|
283
|
+
# Thanks for that 1.8.7 - cant do a simple merge...
|
|
284
|
+
options[key.to_sym] = value unless options.keys.include?(key.to_sym)
|
|
285
|
+
end
|
|
286
|
+
font = Font.new(options)
|
|
287
|
+
font.color = Color.new(:rgb => options[:fg_color]) if options[:fg_color]
|
|
288
|
+
font.name = options[:font_name] if options[:font_name]
|
|
289
|
+
options[:type] == :dxf ? font : fonts << font
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# parses add_style options for fills. If the options hash contains :type => :dxf we return a Fill object. If not, we return the index of the fill after being added to the fills collection.
|
|
293
|
+
# @note noop if :bg_color is not specified in options
|
|
294
|
+
# @option options [String] bg_color The rgb color to apply to the fill
|
|
295
|
+
# @return [Fill|Integer]
|
|
296
|
+
def parse_fill_options(options={})
|
|
297
|
+
return unless options[:bg_color]
|
|
298
|
+
color = Color.new(:rgb=>options[:bg_color])
|
|
299
|
+
dxf = options[:type] == :dxf
|
|
300
|
+
color_key = dxf ? :bgColor : :fgColor
|
|
301
|
+
pattern = PatternFill.new(:patternType =>:solid, color_key=>color)
|
|
302
|
+
fill = Fill.new(pattern)
|
|
303
|
+
dxf ? fill : fills << fill
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# parses Style#add_style options for borders.
|
|
307
|
+
# @note noop if :border is not specified in options
|
|
308
|
+
# @option options [Hash|Integer] A border style definition hash or the index of an existing border.
|
|
309
|
+
# Border style definition hashes must include :style and :color key-value entries and
|
|
310
|
+
# may include an :edges entry that references an array of symbols identifying which border edges
|
|
311
|
+
# you wish to apply the style or any other valid Border initializer options.
|
|
312
|
+
# If the :edges entity is not provided the style is applied to all edges of cells that reference this style.
|
|
313
|
+
# Also available :border_top, :border_right, :border_bottom and :border_left options with :style and/or :color
|
|
314
|
+
# key-value entries, which override :border values.
|
|
315
|
+
# @example
|
|
316
|
+
# #apply a thick red border to the top and bottom
|
|
317
|
+
# { :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] }
|
|
318
|
+
# @return [Border|Integer]
|
|
319
|
+
def parse_border_options(options={})
|
|
320
|
+
return unless options[:border]
|
|
321
|
+
b_opts = options[:border]
|
|
322
|
+
if b_opts.is_a?(Hash)
|
|
323
|
+
raise ArgumentError, (ERR_INVALID_BORDER_OPTIONS % b_opts) unless b_opts.keys.include?(:style) && b_opts.keys.include?(:color)
|
|
324
|
+
border = Border.new b_opts
|
|
325
|
+
(b_opts[:edges] || [:left, :right, :top, :bottom]).each do |edge|
|
|
326
|
+
edge_options = options["border_#{edge}".to_sym] || {}
|
|
327
|
+
border_edge = b_opts.merge(edge_options)
|
|
328
|
+
b_options = { :name => edge, :style => border_edge[:style], :color => Color.new(:rgb => border_edge[:color]) }
|
|
329
|
+
border.prs << BorderPr.new(b_options)
|
|
330
|
+
end
|
|
331
|
+
options[:type] == :dxf ? border : borders << border
|
|
332
|
+
elsif b_opts.is_a? Integer
|
|
333
|
+
raise ArgumentError, (ERR_INVALID_BORDER_ID % b_opts) unless b_opts < borders.size
|
|
334
|
+
if options[:type] == :dxf
|
|
335
|
+
borders[b_opts].clone
|
|
336
|
+
else
|
|
337
|
+
border = b_opts
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
# Parses Style#add_style options for number formatting.
|
|
343
|
+
# noop if neither :format_code or :num_format options are set.
|
|
344
|
+
# @option options [Hash] A hash describing the :format_code and/or :num_fmt integer for the style.
|
|
345
|
+
# @return [NumFmt|Integer]
|
|
346
|
+
def parse_num_fmt_options(options={})
|
|
347
|
+
return if (options.keys & [:format_code, :num_fmt]).empty?
|
|
348
|
+
|
|
349
|
+
#When the user provides format_code - we always need to create a new numFmt object
|
|
350
|
+
#When the type is :dxf we always need to create a new numFmt object
|
|
351
|
+
if options[:format_code] || options[:type] == :dxf
|
|
352
|
+
#If this is a standard xf we pull from numFmts the highest current and increment for num_fmt
|
|
353
|
+
options[:num_fmt] ||= (@numFmts.map{ |num_fmt| num_fmt.numFmtId }.max + 1) if options[:type] != :dxf
|
|
354
|
+
numFmt = NumFmt.new(:numFmtId => options[:num_fmt] || 0, :formatCode=> options[:format_code].to_s)
|
|
355
|
+
options[:type] == :dxf ? numFmt : (numFmts << numFmt; numFmt.numFmtId)
|
|
356
|
+
else
|
|
357
|
+
options[:num_fmt]
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Serializes the object
|
|
362
|
+
# @param [String] str
|
|
363
|
+
# @return [String]
|
|
364
|
+
def to_xml_string(str = '')
|
|
365
|
+
str << '<styleSheet xmlns="' << XML_NS << '">'
|
|
366
|
+
[:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
|
|
367
|
+
self.instance_values[key.to_s].to_xml_string(str) unless self.instance_values[key.to_s].nil?
|
|
368
|
+
end
|
|
369
|
+
str << '</styleSheet>'
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
private
|
|
373
|
+
# Creates the default set of styles the exel requires to be valid as well as setting up the
|
|
374
|
+
# Axlsx::STYLE_THIN_BORDER
|
|
375
|
+
def load_default_styles
|
|
376
|
+
@numFmts = SimpleTypedList.new NumFmt, 'numFmts'
|
|
377
|
+
@numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDD, :formatCode=> "yyyy/mm/dd")
|
|
378
|
+
@numFmts << NumFmt.new(:numFmtId => NUM_FMT_YYYYMMDDHHMMSS, :formatCode=> "yyyy/mm/dd hh:mm:ss")
|
|
379
|
+
|
|
380
|
+
@numFmts.lock
|
|
381
|
+
|
|
382
|
+
@fonts = SimpleTypedList.new Font, 'fonts'
|
|
383
|
+
@fonts << Font.new(:name => "Arial", :sz => 11, :family=>1)
|
|
384
|
+
@fonts.lock
|
|
385
|
+
|
|
386
|
+
@fills = SimpleTypedList.new Fill, 'fills'
|
|
387
|
+
@fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:none))
|
|
388
|
+
@fills << Fill.new(Axlsx::PatternFill.new(:patternType=>:gray125))
|
|
389
|
+
@fills.lock
|
|
390
|
+
|
|
391
|
+
@borders = SimpleTypedList.new Border, 'borders'
|
|
392
|
+
@borders << Border.new
|
|
393
|
+
black_border = Border.new
|
|
394
|
+
[:left, :right, :top, :bottom].each do |item|
|
|
395
|
+
black_border.prs << BorderPr.new(:name=>item, :style=>:thin, :color=>Color.new(:rgb=>"FF000000"))
|
|
396
|
+
end
|
|
397
|
+
@borders << black_border
|
|
398
|
+
@borders.lock
|
|
399
|
+
|
|
400
|
+
@cellStyleXfs = SimpleTypedList.new Xf, "cellStyleXfs"
|
|
401
|
+
@cellStyleXfs << Xf.new(:borderId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
|
|
402
|
+
@cellStyleXfs.lock
|
|
403
|
+
|
|
404
|
+
@cellStyles = SimpleTypedList.new CellStyle, 'cellStyles'
|
|
405
|
+
@cellStyles << CellStyle.new(:name =>"Normal", :builtinId =>0, :xfId=>0)
|
|
406
|
+
@cellStyles.lock
|
|
407
|
+
|
|
408
|
+
@cellXfs = SimpleTypedList.new Xf, "cellXfs"
|
|
409
|
+
@cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
|
|
410
|
+
@cellXfs << Xf.new(:borderId=>1, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0)
|
|
411
|
+
# default date formatting
|
|
412
|
+
@cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>14, :fontId=>0, :fillId=>0, :applyNumberFormat=>1)
|
|
413
|
+
@cellXfs.lock
|
|
414
|
+
|
|
415
|
+
@dxfs = SimpleTypedList.new(Dxf, "dxfs"); @dxfs.lock
|
|
416
|
+
@tableStyles = TableStyles.new(:defaultTableStyle => "TableStyleMedium9", :defaultPivotStyle => "PivotStyleLight16"); @tableStyles.lock
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|