Yongzhong office secondary development _ Secondary Development of Java 2

Source: Internet
Author: User

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/>

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.