Ruby 打开 Word 文档并插入数据
- 摘要:Ruby打开Word文档并插入数据[代码]ruby代码viewsourceprint?1require'win32ole'234word=WIN32OLE.new("word.application")5word['Visible']=TRUE6worddoc=word.documents.add()7worddoc.Content.Text="asdf"8worddoc.SaveAs"Graph.doc"9worddoc
- 标签:文档 Ruby 数据
Ruby 打开 Word 文档并插入数据
[代码] ruby代码
view sourceprint?
1
require 'win32ole'
2
3
4
word=WIN32OLE.new("word.application")
5
word['Visible']=TRUE
6
worddoc=word.documents.add()
7
worddoc.Content.Text="asdf"
8
worddoc.SaveAs "Graph.doc"
9
worddoc.close
[代码] ruby代码
01
require 'win32ole'
02
# Creates OLE object to word
03
word = WIN32OLE.new("word.application")
04
word['Visible'] = TRUE;
05
word.documents.Add
06
0.upto(10){
07
word.selection.TypeText(Text="Hello Ruby Relatives!")
08
word.selection.TypeParagraph
09
}
10
word.close()