这个问题没有去研究,但我想楼主看看Office相关编程会受到一些启示的.
随便说一下,录制宏也是研究office编程的一种方法

解决方案 »

  1.   

    我要实现的无非是把那些word,excel上传,在服务器端转为html,然后再在前台显示出来。
    请高手们想想办法。
    已经一个礼拜了,还没有解决。
      

  2.   

    可以让用户直接把excel生成html不就可以了吗?
    你可看一下pio.jar这个包,我们从数据库导入excel和excel导出数据库用的都是此包,不过我不太清楚其是否有生成html的功能。
      

  3.   

    让用户生成html页,我也考虑过,但是在客户端会生成.files的文件。
    里面有很多内容,这些也要上传。不然显示会有错。
    我是用jacob包做的,现在已经实现了word转html
    但是转excel的时候,只把excel的内容存下来,格式却不对了。
    看生成的目录下没有.files的文件。
      

  4.   

    请问如何实现了word转html?能给我代码啊?
      

  5.   

    package com.esp.dochtml;import java.io.File;
    import com.jacob.com.*;
    import com.jacob.activeX.*;public class Word2Html{

    private String inFile = "";//要转换的word文件
    private String otFile = "";//目标文件
        
        public Word2Html(){
         }
        
        public String setinFile(String filepath)
        {
         inFile = filepath;
         return inFile;
        }
            public String setotFile(String filepath)
        {
         otFile = filepath;
         return otFile;
        }    public boolean convert()
        { ActiveXComponent app = new ActiveXComponent("Word.Application");//启动word
    boolean flag = false;
    try {
    app.setProperty("Visible", new Variant(false));//设置word不可见
    Object docs = app.getProperty("Documents").toDispatch();
    Object doc = Dispatch.invoke(docs,"Open", Dispatch.Method, new Object[]{inFile,new Variant(false), new Variant(true)}, new int[1]).toDispatch();//打开word文件
    Dispatch.invoke(doc,"SaveAs", Dispatch.Method, new Object[]{otFile,new Variant(8)}, new int[1]);//作为html格式保存到临时文件
    Variant f = new Variant(false);
    Dispatch.call(doc, "Close", f);
    flag = true;
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    app.invoke("Quit", new Variant[] {});
    }
    return flag; }
    }
    我在jsp中这样写的:
    <%@ page language="java" import="java.sql.*"%>
    <%@ page contentType="text/html; charset=gb2312" %><%@ page import="java.io.*,java.text.*,java.util.*" %>
    <%@ page import="com.esp.dochtml.*" %><%
    Word2Html wordTohtml = new Word2Html();
    wordTohtml.setinFile("d:\\1111111111.doc");
    wordTohtml.setotFile("d:\\2.html");%>
    也是网络上找到的。
    注意jacob.dll的路径要加到path里。
    你可以参考参考