Overview: yongzhong office is developed using Java, so it is convenient to directly use Java for secondary development. However, it is generally called using VB and VC during client running, therefore, it is necessary to encapsulate it into COM components for other languages to call.
Today, we will continue to developPart 2 call an instanceInstructions:
(If you feel good, I will continue. If you feel bad, this second article will be over)
1. Clear traces
Public static Boolean acceptallrevision (document) <br/>{< br/> document. acceptallrevision (); <br/> return true; <br/>}
2. Insert an image in the bookmarks
Public static Boolean insertpictobookmark (document, string bookmarkname, string picpath, float width, float height) <br/>{< br/> bookmark BK = document. getbookmarks (). get (bookmarkname); <br/> If (BK = NULL) <br/> return false; </P> <p> insertpictotextrange (BK. getrange (), picpath, width, height, true); </P> <p> return true; <br/>}
3. insert an image at the range position
Public static Boolean insertpictotextrange (textrange range, string picpath, float width, float height, Boolean isbefore) <br/>{< br/> If (width * Height = 0) <br/>{< br/> If (isbefore) <br/> range. insertpicturebefore (picpath); <br/> else <br/> range. insertpictureafter (picpath); <br/>}< br/> else <br/>{< br/> If (isbefore) <br/> range. insertpicturebefore (picpath, width, height); <br/> else <br/> range. insertpictureafter (picpath, width, height); <br/>}</P> <p> return true; <br/>}
4. Insert a file in the bookmarks
Public static Boolean insertfiletobookmark (document, string bookmarkname, string filepath) <br/>{< br/> string T = filepath. tolowercase (); <br/> If (! (T. contains (". doc ") | T. contains (". rtf ") | T. contains (". EIO ") | T. contains (". EIT ") | T. contains (". TXT ") <br/> return false; <br/> bookmark BK = document. getbookmarks (). get (bookmarkname); <br/> If (BK = NULL) <br/> return false; </P> <p> document. setoffset (BK. getendposition (); <br/> document. insertdocument (2, filepath, null); </P> <p> return true; <br/>}< br/>
5. Insert a file at the range location
Public static Boolean insertfiletotextrange (document, textrange range, string filepath) <br/>{< br/> string T = filepath. tolowercase (); <br/> If (! (T. contains (". doc ") | T. contains (". rtf ") | T. contains (". EIO ") | T. contains (". EIT ") | T. contains (". TXT ") <br/> return false; <br/> If (range = NULL) <br/> return false; <br/> document. setoffset (range. getendoffset (); <br/> document. insertdocument (2, filepath, null); <br/> return true; <br/>}
6. Insert a table
Public static Boolean inserttabletodocument (document, textrange range, string tablename, int rowcount, int columncount) <br/>{< br/> If (range = NULL) <br/> return false; </P> <p> document. gettables (). addtable (range, rowcount, columncount, tablename, tableconstants. autofit_content, 0); </P> <p> return true; <br/>}
7. Protection and solution Protection Documents
Public static Boolean protectdocument (document, int protecttype) <br/>{< br/> document. protect (protecttype, docpassword); <br/> return true; <br/>}</P> <p> Public static Boolean unprotectdocument (document) <br/>{< br/> document. unprotect (docpassword); <br/> return true; <br/>}< br/>