façade object is not known.
Example facadeFor example, we usually use the computer, the Desktop file shortcut ( or an executable file ), we need to do is just open and close, usually do not need to consider what to open ah, set what parameters Ah, How to destroy resources when shutting down to ensure that the program's data can not cause loss .... This executable file can be seen as a façade . Because it greatly simplifies our operations, and we can completely ignore the interaction between
First, the class library is introduced, Microsoft.Office.Interop.Word, and then programmed. The code is as follows:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Office.Interop.Word; namespace Wordtest { public partial class Form1:form { Object strFileName; Object Nothing; Microsoft.Office.Interop.Word.Application Mywordapp = new Microsoft.Offic
Http://forum.java.sun.com/thread.jsp? Forum = 40 thread = 382666 tstart = 0 trange = 15
A jacob
OperationWord example,
OperationIn the examples of Excel, Access, and Outlook, jacob's sample directory contains
Import java. io. File;
Import com.jacb.com .*;
Import com. jacob. activeX .*;
Public class WordTest {
Public static void main (String [] args ){
WordBean word = new WordBean ();
Word. openWord (true );
Word. createNewDocument ();
W
"; // name of the program to be startedP. startinfo. Arguments = "-x sourcefile. ARJ c: \ Temp"; // startup ParameterP. Start (); // startIf (P. hasexisted) // determines whether the running is completed.P. Kill ();
3. Read the word content and display it in the control.
Add a button and a RichTextBox to form, and add a click event to the button.Private void button#click (Object sender, eventargs E){Object filepath = "d :\\ debugtest.doc ";Openword (
generated file in todo, go* Window-preferences-Java-code style-Code Template*/Package poitest;
Import com. Jacob. ActiveX .*;Import com.jacb.com .*;
Public class wordbean extends java. AWT. Panel{Private activexcomponent mswordapp = NULL;Private dispatch document = NULL;Public wordbean (){Super ();}
Public void openword (Boolean makevisible){// Open word if we/'ve not done it alreadyIf (mswordapp = NULL){Mswordapp = new activexcomponent ("word. appli
;
Private object worddoc = NULL;
Private Final variant false = new variant (false );
Private Final variant true = new variant (true );
/***//**
* Open a Word document
*
* @ Param filepath
* Word documents
* @ Return returns the Word Document Object.
*/
Public Boolean openword (string filepath )...{
// Create ActiveX parts
Wordcom = new activexcomponent ("word. application ");
Try ...{
// Return the dispatch of wrdcom. Documents.
Dispatch wrddocs
The requirement of a recent project is to replace the content of the character in the record set with the specific content of the Word document template to generate different documents. In two steps:
1. Copy the template content to a Document object. Copy the content from the source DOC Document and return a Document class. # region returns a Document class from the source DOC Document copy content.
/// /// Copy the content from the source DOC file and return a Document class
/// /// /// Pr
When you open a Word file with MFC, you need to import the. olb file.Select from a Type Library by View/classwizard->add class on the vc++6.0 toolbar ... Locate the required library file import.The path used in this example is:C:\Program Files\Microsoft Office\office11\msword. OLB.(1), shown in Figure (2):
Figure (1) Import Msword.olb file
Figure (2) Press "ctlr+ left mouse button" to import the corresponding class, such as _application, Documents, _docum
/15311.shtm
Http://forum.java.sun.com/thread.jsp? Forum = 40 thread = 382666 tstart = 0 trange = 15
An example of jacob's Word operations, Excel, Access, and Outlook operations, is in the jacob's sample directory.
Import java. io. File;
Import com.jacb.com .*;
Import com. jacob. activeX .*;
Public class WordTest {
Public static void main (String [] args ){
WordBean word = new WordBean ();
Word. openWord (true );
Word. createNewDocument ();
Wo
Java operations PDF http://www.lowagie.com/Java operation Word, Excel, accessRefer:Http://danadler.com/jacob/Http://jakarta.apache.org/poi/Http://www.onjava.com/pub/a/onjava/2003/01/22/poi.htmlHttp://www.csdn.net/develop/article/15/15311.shtmHttp://forum.java.sun.com/thread.jsp? Forum = 40 Thread = 382666 tstart = 0 trange = 15Java Excel API documentationHttp://www.andykhan.com/jexcelapi/
1. An example of Jacob's word operations. Other operations such as Excel and PDF are available in the sam
Refer:
Http://danadler.com/jacob/Http://jakarta.apache.org/poi/Http://www.onjava.com/pub/a/onjava/2003/01/22/poi.htmlHttp://www.csdn.net/develop/article/15/15311.shtmHttp://forum.java.sun.com/thread.jsp? Forum = 40 Thread = 382666 tstart = 0 trange = 15
Java Excel API documentation
Http://www.andykhan.com/jexcelapi/
1. An example of Jacob's word operations. Other operations such as Excel and PDF are available in the sample.
Import java. Io. file;Import com.jacb.com .*;Import com. Jacob. Activ
voidButton1_Click (Objectsender, EventArgs e) { if(Openfiledialog1.showdialog ()! =System.Windows.Forms.DialogResult.OK) {return; } stringstr = openfiledialog1.filename;//this simulates the downloaded file in the form of a select file. ObjectSorcedocpath = str;//path to the download file #regionOpen Word to copy contentObjectReadOnly =false; ObjectIsVisible =false; Object Nothing=System.Reflection.Missing.Value; ObjectObjdoctype =wddocumenttype.wdtype
ASP tutorial. NET C # Word files operations1, reference
You need to reference a COM library: Microsoft Word 11.0 the Object library. Different versions, there will be different version numbers.
such as version 2010 Office is the Microsoft Word 14.0 Object Library.
2, refer to the corresponding name space:
Using Microsoft.Office.Core;
Using Word = Microsoft.Office.Interop.Word;
3. Open an existing Word document
public void Opendocfile (string docname){object omissing = System.Reflection.
Hi,
This is an extended question to http://www.experts-exchang
E.com/Prog
Ramming/La
Nguages/
C _
Sharp/Q_23
183926. htm
L.
I have
Added
A memorystream to a webbrowser:
Public WebBrowser createEmbeddedWord (Point point, MemoryStream memoryStream){WebBrowser = new WebBrowser ();WebBrowser. Location = point;Size size = new Size (new Point (200,200 ));WebBrowser. Size = size;WebBrowser. DocumentStream = memoryStream;Return webBrowser;}
And when I run the program it displays the text in the webb
conveniently, and it doesn't require you to install MS Office to work with Word.One, NuGet package installation Dll filesFigure 1-1 Opening the NuGet Package ManagerFigure 1-2 3 more reference files after installationSecond, the beginning does not say "Hello world", read all poetry also in vain1. Create a blank "demo1.docx" file firstFigure 2-12. Write a few lines of code1 Public Partial classForm1:form2 {3 PublicForm1 ()4 {5 InitializeComponent ();6 }7 8
Object}catch (Exception e) {e.printstacktrace ();}} }
For example 2:openword.java, open an existing Word document.
/****************************************** *openword.java *openaworddocument * *version1.0 *authorHowwa@sina.com http://blog.sina.com.cn/u/1495389370 *******************************************/
IMPORTORG.JAWIN.DISPATCHPTR; Importorg.jawin.win32.Ole32;
public class openword{public static void Main (String[]args) {try{ole32.coinitialize
This article mainly introduces the executable file (Sample Code) of the JavaScript client call. If you need it, you can refer to it for help.
The Code is as follows:
Script
Function openNotepad (){Var wsh = new ActiveXObject ("wscript. shell ")Wsh. run ("notepad.exe") // if you can run it in "run", you can directly write it here; otherwise, you must write the absolute path.}
Function openWord (){Var wsh = new ActiveXObject ("wscript. shell
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.