我只知道在SPS里可以做到但是SERVER也必须装OFFICE

解决方案 »

  1.   

    请问如何让一个java程序在开机的时候就执行????/急...
      

  2.   

    用jsp读出.doc文件流应该可以做到直接再网页上打开!
      

  3.   

    <%@ page contentType="application/msword;charset=GBK"  %>
    <%@ page language="java" import="java.io.*"%>
    <body>
    <%
    try
    {
    File ff = new File("d:/1.doc");
    int ln = (int)ff.length();FileInputStream in = new FileInputStream(ff);byte data[] = new byte[ln];
    in.read(data);
    in.close();
    response.reset();
    response.setContentType("application/msword,charset=gb2312");
        response.setHeader("Content-disposition","attachment; filename=temp.doc");OutputStream os = null;
    os = response.getOutputStream();
    if(os==null)
    out.println("os is null");
    else
    {
    os.write(data);
    os.flush();
    }
    os.close();
    }catch(Exception ex)
    {
    ex.printStackTrace();
    System.out.println(ex.getMessage());
    }
    %>
    </body>在web.xml中添加下面的代码:<mime-mapping> 
      <extension>doc</extension> 
      <mime-type>application/msword</mime-type> 
    </mime-mapping>