Method: Writeexcel::Format#set_rotation

Defined in:
lib/writeexcel/format.rb

#set_rotation(rotation) ⇒ Object

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

Default state:      Text rotation is off
Default action:     None
Valid args:         Integers in the range -90 to 90 and 270

Set the rotation of the text in a cell. The rotation can be any angle in the range -90 to 90 degrees.

format = workbook.add_format
format.set_rotation(30)
worksheet.write(0, 0, 'This text is rotated', format)

The angle 270 is also supported. This indicates text where the letters run from top to bottom.



1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
# File 'lib/writeexcel/format.rb', line 1220

def set_rotation(rotation)
  # 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