Ruby/Windows Platform/Word
Материал из Wiki.crossplatform.ru
Содержание |
Microsoft Word document
require "win32ole" # Creates OLE object to word word = WIN32OLE.new("word.application") word["Visible"] = TRUE; word.documents.Add 0.upto(10){ word.selection.TypeText(Text="Hello Ruby Relatives!") word.selection.TypeParagraph } word.close()
Open a word file and print it out
require "win32ole" docfile = "yourDoc.doc" word = WIN32OLE.new "Word.Application" word.visible = true word.documents.open docfile word.options.printBackground = false word.activeDocument.printOut word.quit
Using WIN32OLE with word
require "win32ole" wordobj = WIN32OLE.new("word.application") wordobj.documents.add()
Write the Code to Insert Data into Word
require "win32ole" word=WIN32OLE.new("word.application") word["Visible"]=TRUE worddoc=word.documents.add() worddoc.Content.Text="asdf" worddoc.SaveAs "Graph.doc" worddoc.close