Word文件数据显示在页面上

ActiveXComponent app = new ActiveXComponent("Word.Application");  
        app.setProperty("Visible", new Variant(false));  
        Dispatch doc1 = app.getProperty("Documents").toDispatch();  
        //打开aaaa.doc  
        Dispatch doc2 = Dispatch.invoke(  
            doc1,   
            "Open",   
            Dispatch.Method,  
            new Object[]{"d://tt.doc", new Variant(false), new Variant(true)},  
            new int[1]  
        ).toDispatch();  
        //另存为aaaa.html  
        String name="aaaa.html";
        Dispatch.invoke(  
            doc2,  
            "SaveAs",   
            Dispatch.Method,   
            new Object[]{  
                "d://"+name,   
                new Variant(8)//7为txt格式, 8保存为html格式  
            },   
            new int[1]  
        );  
        Variant f = new Variant(false);  
        Dispatch.call(doc2, "Close", f);
        
        File file = new File("d://aaaa.html");
        String realPath = ServletActionContext.getServletContext()
                .getRealPath("/images");
        File filetemp = new File(realPath);
        File f1 = new File(filetemp, "aaaa.html");
        try {
            FileUtils.copyFile(file, f1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "success";


使用jacob-1.17来完成word转换


转换成HTML文件,然后上传到服务器上,通过服务器路径读取出来,显示在页面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值