Generating Word documents with Java Apache POI __java

Source: Internet
Author: User

Need to implement the ability to export Word documents, online about POI generation of Word documents, few examples, looking for a long time to find a demo in the official website, with a demo everything will be good to do.

[Java]  View Plain copy/* ====================================================================      Licensed to the Apache Software Foundation  (ASF)  under one  or more     contributor license agreements.  see the  NOTICE file distributed with     this work for  additional information regarding copyright ownership.     The ASF  licenses this file to you under the apache license, version  2.0      (the  "License");  you may not use this file  except in compliance with     the License.  You  may obtain a copy of the license at            http://www.apache.org/licenses/license-2.0       Unless required by  applicable law or agreed to in writing, software      distributed under the license is distributed on an  "AS IS"   basis,     without warranties or conditions of any kind,  either express or implied.     see the license for  the specific language governing permissions and      limitations under the license.  =========================================================== ========= */   package org.apache.poi.xwpf.usermodel;      import  java.io.fileoutputstream;     /**   * A SIMPLE WORDPROCESSINGML  document created by poi xwpf api   *   *  @author  Yegor Kozlov   */    public class simpledocument {          public  static void main (String[] args)  throws Exception {            xwpfdocument doc = new xwpfdocument ();              XWPFParagraph p1 =  Doc.createparagraph ();           p1.setalignment ( Paragraphalignment.center);           p1.setborderbottom ( borders.double);           p1.setbordertop (Borders.DOUBLE);               p1.setborderright (borders.double);        &NBsp;   p1.setborderleft (borders.double);            p1.setborderbetween (borders.single);               p1.setverticalalignment (textalignment.top);               xwpfrun r1 = p1.createrun ();            r1.setbold (True);           r1.settext ("The quick  brown fox ");           r1.setbold (True);            r1.setfontfamily ("Courier");            r1.setunderline (underlinepatterns.dot_dot_dash);            r1.settextposition (m);             &nbSp; xwpfparagraph p2 = doc.createparagraph ();            p2.setalignment (paragraphalignment.right);               //BORDERS            P2.setborderbottom (borders.double);           p2.setbordertop (borders.double);           p2.setborderright (Borders.DOUBLE) ;           p2.setborderleft (Borders.DOUBLE);           p2.setborderbetween (borders.single);              xwpfrun r2 = p2.createrun ();  

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.