summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/stylesheet/cell_style.rb
blob: 3bc9faeca68aa0907b380ec46bed4c73ca075427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# frozen_string_literal: true

module Axlsx
  # CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
  # @note Using Styles#add_style is the recommended way to manage cell styling.
  # @see Styles#add_style
  class CellStyle
    include Axlsx::OptionsParser
    include Axlsx::SerializedAttributes

    # Creats a new CellStyle object
    # @option options [String] name
    # @option options [Integer] xfId
    # @option options [Integer] buildinId
    # @option options [Integer] iLevel
    # @option options [Boolean] hidden
    # @option options [Boolean] customBuiltIn
    def initialize(options = {})
      parse_options options
    end

    serializable_attributes :name, :xfId, :buildinId, :iLevel, :hidden, :customBuilin

    # The name of this cell style
    # @return [String]
    attr_reader :name

    # The formatting record id this named style utilizes
    # @return [Integer]
    # @see Axlsx::Xf
    attr_reader :xfId

    # The buildinId to use when this named style is applied
    # @return [Integer]
    # @see Axlsx::NumFmt
    attr_reader :builtinId

    # Determines if this formatting is for an outline style, and what level of the outline it is to be applied to.
    # @return [Integer]
    attr_reader :iLevel

    # Determines if this named style should show in the list of styles when using Excel
    # @return [Boolean]
    attr_reader :hidden

    # Indicates that the build in style reference has been customized.
    # @return [Boolean]
    attr_reader :customBuiltin

    # @see name
    def name=(v) Axlsx.validate_string v; @name = v end
    # @see xfId
    def xfId=(v) Axlsx.validate_unsigned_int v; @xfId = v end
    # @see builtinId
    def builtinId=(v) Axlsx.validate_unsigned_int v; @builtinId = v end
    # @see iLivel
    def iLevel=(v) Axlsx.validate_unsigned_int v; @iLevel = v end
    # @see hidden
    def hidden=(v) Axlsx.validate_boolean v; @hidden = v end
    # @see customBuiltin
    def customBuiltin=(v) Axlsx.validate_boolean v; @customBuiltin = v end

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      serialized_tag('cellStyle', str)
    end
  end
end