class WordWps::Table

表格

Constants

Alignment
Height
LineStyle
Style

Public Class Methods

new(selection, row, col, obj) click to toggle source
# File lib/word_wps.rb, line 408
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/word_wps.rb, line 436
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/word_wps.rb, line 478
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/word_wps.rb, line 467
def center
        select_all
        now.ParagraphFormat.Alignment = 1
end
height=(point) click to toggle source

设置行高

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

合并列

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

放入数据

# File lib/word_wps.rb, line 428
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/word_wps.rb, line 473
def select_all
        @obj.Select
end
set_columns_width(col, point) click to toggle source

设置列宽度

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

设置风格

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

移动到第一个单元格

# File lib/word_wps.rb, line 462
def top
        @obj.Cell(1,1).Select
end