Method: Format#set_rotation

Defined in:
lib/WriteExcel/format.rb

#set_rotation(rotation) ⇒ Object

set_rotation($angle)

Set the rotation angle of the text. An alignment property.



1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
# File 'lib/WriteExcel/format.rb', line 1014

def set_rotation(rotation)
  # Argument should be a number
  return unless rotation.kind_of?(Numeric)

  # The arg type can be a double but the Excel dialog only allows integers.
  rotation = rotation.to_i

  #      if (rotation == 270)
  #         rotation = 255
  #      elsif (rotation >= -90 or rotation <= 90)
  #         rotation = -rotation +90 if rotation < 0;
  #      else
  #         # carp "Rotation $rotation outside range: -90 <= angle <= 90";
  #         rotation = 0;
  #      end
  #
  if rotation == 270
    rotation = 255
  elsif rotation >= -90 && rotation <= 90
    rotation = -rotation + 90 if rotation < 0
  else
    rotation = 0
  end

  @rotation = rotation;
end