class Axlsx::Border

This class details a border used in Office Open XML spreadsheet styles.

Attributes

diagonalDown[R]

@return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.

diagonalUp[R]

@return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.

diagonal_down[R]

@return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.

diagonal_up[R]

@return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.

outline[R]

@return [Boolean] The outline property for the border indicating that top, left, right and bottom borders should only be applied to the outside border of a range of cells.

prs[R]

@return [SimpleTypedList] A list of BorderPr objects for this border.

Public Class Methods

new(options={}) click to toggle source

Creates a new Border object @option options [Boolean] diagonal_up @option options [Boolean] diagonal_down @option options [Boolean] outline @example - Making a border

p = Axlsx::Package.new
red_border = p.workbook.styles.add_style :border => { :style => :thin, :color => "FFFF0000" }
ws = p.workbook.add_worksheet
ws.add_row [1,2,3], :style => red_border
p.serialize('red_border.xlsx')

@note The recommended way to manage borders is with Style#add_style @see Style#add_style

# File lib/axlsx/stylesheet/border.rb, line 22
def initialize(options={})
  @prs = SimpleTypedList.new BorderPr
  parse_options options
end

Public Instance Methods

diagonalDown=(v)
Alias for: diagonal_down=
diagonalUp=(v)
Alias for: diagonal_up=
diagonal_down=(v) click to toggle source

@see diagonalDown

# File lib/axlsx/stylesheet/border.rb, line 48
def diagonal_down=(v) Axlsx::validate_boolean v; @diagonal_down = v end
Also aliased as: diagonalDown=
diagonal_up=(v) click to toggle source

@see diagonalUp

# File lib/axlsx/stylesheet/border.rb, line 44
def diagonal_up=(v) Axlsx::validate_boolean v; @diagonal_up = v end
Also aliased as: diagonalUp=
outline=(v) click to toggle source

@see outline

# File lib/axlsx/stylesheet/border.rb, line 52
def outline=(v) Axlsx::validate_boolean v; @outline = v end
to_xml_string(str = '') click to toggle source

Serializes the object @param [String] str @return [String]

# File lib/axlsx/stylesheet/border.rb, line 57
def to_xml_string(str = '')
  str << '<border '
  serialized_attributes str
  str << '>'
  # enforces order
  [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
    @prs.select { |pr| pr.name == k }.each do |part|
      part.to_xml_string(str)
    end
  end
  str << '</border>'
end