当前位置: 移动技术网 > IT编程>移动开发>Android > Android根据word模板文档将表单数据生成word文档的方案整理

Android根据word模板文档将表单数据生成word文档的方案整理

2019年04月30日  | 移动技术网IT编程  | 我要评论

魅妾,宾客期望的酒店管理,刘为娜

版权声明:本文为haiyuking原创文章,转载请注明出处!

前言

尝试的方案包括以下几种:

freemarker

  • 只能在java项目上运行,无法在android项目上运行;

参考资料:《freemarkerjavademo【android将表单数据生成word文档的方案之一(基于freemarker2.3.28,只能java生成)】

poi

  • 解析doc文件可以在android项目上运行;
  • 解析docx文件只能在java项目上运行,无法在android项目上运行;
  • 暂时未实现替换图片功能;

参考资料:《poidemo【android将表单数据生成word文档的方案之二(基于poi4.0.0)】》【目前使用这个

poidocxdemo【android将表单数据生成word文档的方案之二(基于poi4.0.0),目前只能java生成】

jword

  • 即支持java项目也支持android项目;
  • 需要花钱(jword只有30天的试用期,过期需要购买,299欧元forever~~2129.1491人民币元)

 参考资料:《》

demo中的替换文本用法很简单:

import com.independentsoft.office.word.worddocument;

public class example {

    public static void main(string[] args)
    {
        try
        {
            worddocument doc = new worddocument("c:\\test\\input.docx");

            doc.replace("[customerid]", "12345");
            doc.replace("[customername]","john smith");

            doc.save("c:\\test\\output.docx", true);
        }
        catch (exception e)
        {
            system.out.println(e.getmessage());
            e.printstacktrace();
        }
    }
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网