class Aio::Base::Toolkit::WordWps::Table

表格

Constants

Alignment
Height
LineStyle
Style

Public Class Methods

new(selection, row, col, obj) click to toggle source
# File lib/aio/base/toolkit/word_wps.rb, line 414
def initialize(selection, row, col, obj)
  @row = row
  @col = col
  @count = row * col
  @selection = selection
  @obj = obj
end

Public Instance Methods

<<(arr) click to toggle source

放入数据, 可以按数组放入

# File lib/aio/base/toolkit/word_wps.rb, line 442
def <<(arr)
  case arr
  when ::String
    puts(arr)
  when ::Array
    arr.each { |a| puts(a) }
  end
end
border_line() click to toggle source

网格线

# File lib/aio/base/toolkit/word_wps.rb, line 484
def border_line
  select_all
  now.Borders(-1).LineStyle = 1
  now.Borders(-2).LineStyle = 1
  now.Borders(-3).LineStyle = 1
  now.Borders(-4).LineStyle = 1
  now.Borders(-5).LineStyle = 1
  now.Borders(-6).LineStyle = 1
end
center() click to toggle source

居中

# File lib/aio/base/toolkit/word_wps.rb, line 473
def center
  select_all
  now.ParagraphFormat.Alignment = 1
end
height=(point) click to toggle source

设置行高

# File lib/aio/base/toolkit/word_wps.rb, line 452
def height=(point)
  now.Rows.Height = point
end
merge_row() click to toggle source

合并列

# File lib/aio/base/toolkit/word_wps.rb, line 427
def merge_row
  now.SelectRow
  now.Cells.Merge
  @count = @count - @row + 1
end
now() click to toggle source
# File lib/aio/base/toolkit/word_wps.rb, line 422
def now
  @selection
end
puts(str) click to toggle source

放入数据

# File lib/aio/base/toolkit/word_wps.rb, line 434
def puts(str)
  now.SelectCell
  now.TypeText(str)
  @count -= 1
  now.MoveRight(12) unless @count < 1
end
select_all() click to toggle source

选择整个表格

# File lib/aio/base/toolkit/word_wps.rb, line 479
def select_all
  @obj.Select
end
set_columns_width(col, point) click to toggle source

设置列宽度

# File lib/aio/base/toolkit/word_wps.rb, line 463
def set_columns_width(col, point)
  @obj.Columns(col).SetWidth(point, 2)
end
style=(sty) click to toggle source

设置风格

# File lib/aio/base/toolkit/word_wps.rb, line 457
def style=(sty)
  select_all
  now.Style = sty
end
top() click to toggle source

移动到第一个单元格

# File lib/aio/base/toolkit/word_wps.rb, line 468
def top
  @obj.Cell(1,1).Select
end