一个struts2框架的数据
  <table width="332" height="62" border="1" align="center">
<tr>
      <td width="194" align="center" valign="middle">区分</td>
      <td width="213">总数</td>
    </tr>
<tr>
    <s:iterator value="totalList">
      <td align="center" valign="middle">&nbsp;<s:property value="pc_type"></s:property></td>
      <td><s:property value="total_count"></s:property></td>
    </tr>
    </s:iterator>
</table>只是简单的一个表格,循环遍历的数据...旁边有一个按钮,只要点击的倒出数据,希望就弹出excel表格,,,数据都在上面...这个不知道怎么做啊?

解决方案 »

  1.   

    http://www.w3sky.com/2/2098.html
    google了一下,这里有用VBScirpt做生成Excel的操作例子
      

  2.   

    在JSP头部加上:
    <%@ page
    language="java"
    contentType="application/vnd.ms-excel;charset=GB2312"
    pageEncoding="GB2312"
    %>
    然后页面就只有<table><tr><td>等元素
    然后访问这个jsp,就是excel文件了,会问你是保存还是打开
      

  3.   

    點按钮后,彈出新窗口,指向繪製的Excel就可以了。
    可以用POI創建Excel。
    http://poi.apache.org/
    點左側的HSSF->Quick Guide
    裏面有很多現成的例子。
    它的包在網站上有下載
      

  4.   

    http://www-128.ibm.com/developerworks/cn/java/l-javaExcel/研究一下吧,看是不是你要的
      

  5.   

    4楼,5楼各说了一种对于简单的excel 4楼的比较好。
    表格比较复杂的话可以用5楼的POI Java API
    http://poi.apache.org/另外,最近比较流行的API还有 JXL(Java Excel API)
    http://jexcelapi.sourceforge.net/
      

  6.   

    请参考:
    http://www.99inf.net/SoftwareDev/Java/51760.htm
      

  7.   

    public class GongdanExcel{        public static void main(String args[]) throws FileNotFoundException, ServletException{       //调试地址,正式使用时放在服务器上       OutputStream os = new FileOutputStream("D:\\test.xls");       writeExcel(os);    }    /**    * 输出Excel    *    * @param os    */    public static void writeExcel(OutputStream os) throws ServletException    {       try       {           /**           * 只能通过API提供的工厂方法来创建Workbook,而不能使用WritableWorkbook的构造函数,           * 因为类WritableWorkbook的构造函数为protected类型           * method(1)直接从目标文件中读取WritableWorkbook wwb = Workbook.createWorkbook(new File(targetfile));           * method(2)如下实例所示 将WritableWorkbook直接写入到输出流           */           WritableWorkbook wwb = Workbook.createWorkbook(os);
             
               //创建Excel工作表 指定名称和位置           WritableSheet ws = wwb.createSheet("test",0);           //**************往工作表中添加数据*****************     
               Label l=null;
               l=new Label(0, 0, "书名");
               ws.addCell(l);
               l=new Label(1, 0, "其他");
               ws.addCell(l);
                          //写入工作表           wwb.write();           wwb.close();       }       catch(Exception e)       {           throw new ServletException(e);        }    }} 
    需要JXL.jar包