在网上搜的时候,有很多java创建word的方法,可是感觉不是我想要的,我想实现的就是通过java新创建一个word文档,然后再用Runtime类打开它,然后在上面操作。然后之前用 
RtfWriter2.getInstance(document,new FileOutputStream("F:\\111.doc"));这个创建了一个word,可是好像编辑有问题,会显示此文档只可读。
然后我又用了java2word,可是只要卸载那个软件,即使我导入java2word.jar也没法使用了,但是我想做出来的东西最后也要生成exe文件,这样java2word也就不可用了
我想说有办法解决我的问题吗?求大神指教!!!!JavaWord

解决方案 »

  1.   

    可以发代码吗?就是只创建一个空白word不读也不写的,这样用word还能打开进行操作吗?
      

  2.   

    docx4j写 Open Office XML 格式的 Word 文档(docx)打开文件使用 Desktop的open 方法调用系统默认的关联程序打开文件。
      

  3.   


    public static void main(String[] args) throws IOException {
    XWPFDocument doc = new XWPFDocument(); 
    XWPFParagraph p1 = doc.createParagraph();
    XWPFRun r1 = p1.createRun();
    r1.setText("hello world");
    FileOutputStream out = new FileOutputStream("D:\\simple.docx"); 
    doc.write(out);  
    out.close(); 
    }
    需要poi的jar包,另外还需要xmlbeans-2.3.0.jar和dom4j-1.6.1.jar,自己可以去网上找下!
      

  4.   

    docx4j生成一个空白的docx文件,并使用默认的关联程序word打开:
    File wordoc = new File("example.docx");
    WordprocessingMLPackage.createPackage().save(wordoc);Desktop.getDesktop().open(wordoc);
    //Desktop.getDesktop().edit(wordoc);
      

  5.   


    public static void main(String[] args) throws IOException {
    XWPFDocument doc = new XWPFDocument(); 
    XWPFParagraph p1 = doc.createParagraph();
    XWPFRun r1 = p1.createRun();
    r1.setText("hello world");
    FileOutputStream out = new FileOutputStream("D:\\simple.docx"); 
    doc.write(out);  
    out.close(); 
    }
    需要poi的jar包,另外还需要xmlbeans-2.3.0.jar和dom4j-1.6.1.jar,自己可以去网上找下!
    我有试你写的这个,可是运行有错,
      

  6.   


    public static void main(String[] args) throws IOException {
    XWPFDocument doc = new XWPFDocument(); 
    XWPFParagraph p1 = doc.createParagraph();
    XWPFRun r1 = p1.createRun();
    r1.setText("hello world");
    FileOutputStream out = new FileOutputStream("D:\\simple.docx"); 
    doc.write(out);  
    out.close(); 
    }
    需要poi的jar包,另外还需要xmlbeans-2.3.0.jar和dom4j-1.6.1.jar,自己可以去网上找下!
    我有试你写的这个,可是运行有错,
    什么错误?
      

  7.   

    我推荐用freeer ,,我这里的例子是生成html ,但是原理是一样的。http://blog.csdn.net/ch656409110/article/details/7832474
    另外关于模板可以这样,先创建一个空的word 文档,将它另存为xml格式,这里面的标签就可以当做模板,之后想要放内容,可以直接通过paramMap往里面放。。只要会点 freeer语法就好了