Class: WordWps::Table
- Inherits:
-
Object
- Object
- WordWps::Table
- Defined in:
- lib/word_wps.rb
Overview
表格
Instance Method Summary collapse
-
#<<(arr) ⇒ Object
放入数据, 可以按数组放入.
-
#border_line ⇒ Object
网格线.
-
#center ⇒ Object
居中.
-
#height=(point) ⇒ Object
设置行高.
-
#initialize(selection, row, col, obj) ⇒ Table
constructor
A new instance of Table.
-
#merge_row ⇒ Object
合并列.
- #now ⇒ Object
-
#puts(str) ⇒ Object
放入数据.
-
#select_all ⇒ Object
选择整个表格.
-
#set_columns_width(col, point) ⇒ Object
设置列宽度.
-
#style=(sty) ⇒ Object
设置风格.
-
#top ⇒ Object
移动到第一个单元格.
Constructor Details
#initialize(selection, row, col, obj) ⇒ Table
Returns a new instance of Table.
407 408 409 410 411 412 413 |
# File 'lib/word_wps.rb', line 407 def initialize(selection, row, col, obj) @row = row @col = col @count = row * col @selection = selection @obj = obj end |
Instance Method Details
#<<(arr) ⇒ Object
放入数据, 可以按数组放入
435 436 437 438 439 440 441 442 |
# File 'lib/word_wps.rb', line 435 def <<(arr) case arr when ::String puts(arr) when ::Array arr.each { |a| puts(a) } end end |
#border_line ⇒ Object
网格线
477 478 479 480 481 482 483 484 485 |
# File 'lib/word_wps.rb', line 477 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 ⇒ Object
居中
466 467 468 469 |
# File 'lib/word_wps.rb', line 466 def center select_all now.ParagraphFormat.Alignment = 1 end |
#height=(point) ⇒ Object
设置行高
445 446 447 |
# File 'lib/word_wps.rb', line 445 def height=(point) now.Rows.Height = point end |
#merge_row ⇒ Object
合并列
420 421 422 423 424 |
# File 'lib/word_wps.rb', line 420 def merge_row now.SelectRow now.Cells.Merge @count = @count - @row + 1 end |
#now ⇒ Object
415 416 417 |
# File 'lib/word_wps.rb', line 415 def now @selection end |
#puts(str) ⇒ Object
放入数据
427 428 429 430 431 432 |
# File 'lib/word_wps.rb', line 427 def puts(str) now.SelectCell now.TypeText(str) @count -= 1 now.MoveRight(12) unless @count < 1 end |
#select_all ⇒ Object
选择整个表格
472 473 474 |
# File 'lib/word_wps.rb', line 472 def select_all @obj.Select end |
#set_columns_width(col, point) ⇒ Object
设置列宽度
456 457 458 |
# File 'lib/word_wps.rb', line 456 def set_columns_width(col, point) @obj.Columns(col).SetWidth(point, 2) end |
#style=(sty) ⇒ Object
设置风格
450 451 452 453 |
# File 'lib/word_wps.rb', line 450 def style=(sty) select_all now.Style = sty end |
#top ⇒ Object
移动到第一个单元格
461 462 463 |
# File 'lib/word_wps.rb', line 461 def top @obj.Cell(1,1).Select end |