<%@ page language="java" import="java.util.*,com.wms.system.UtilDate" pageEncoding="UTF-8"%>
<%@ page contentType="application/vnd.ms-excel;charset=utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/WEB-INF/my.tld" prefix="page" %>
<% 
response.setHeader("Content-disposition","inline; filename=Packing list.xls");
out.clear();
%>
<%int temp=1; %>
<link rel="stylesheet" type="text/css" href="/wms/css/tr.css">
<%=AddExcelHead()%>
<table ;100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="center" colspan="14" rowspan="5">
                    <font size="6">分配管理号</font>
                </td>
                <td align="right" colspan="3" rowspan="5">
                    <img src="&lt;%="
http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()+"/"%>/images/LogoAL.jpg"/&gt;
                </td>
            </tr>
        </table>
        <table ;100%" border="1" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right" colspan="3">
                    收货订单编号
                </td>
                <td align="left" colspan="3">
                    &nbsp;${requestScope.orderList[0].orderNumber }
                </td>
                <td align="right" colspan="3">
                    仓库
                </td>
                <td align="left" colspan="3">
                    &nbsp;${requestScope.orderList[0].stockName }
                </td>
                <td align="right" colspan="3">
                    订单创建人
                </td>
                <td align="left" colspan="2">
                    &nbsp;${requestScope.orderList[0].userName }
                </td>
            </tr>
            <tr>
                <td align="right" colspan="3">
                    客户
                </td>
                <td align="left" colspan="9">
                    &nbsp;${requestScope.orderList[0].customersName }
                </td>
                <td align="right" colspan="3">
                    订单创建日期
                </td>
                <td align="left" colspan="2">
                    &nbsp;${requestScope.orderList[0].createDate }
                </td>
            </tr>
            <tr>
                <td align="right" colspan="3">
                    供应商
                </td>
                <td align="left" colspan="14">
                    &nbsp;${requestScope.orderList[0].providerName }
                </td>
            </tr>
           
           
           
           
        </table>
        管理号
        <table ;100%" border="1" cellspacing="0" cellpadding="0">
            <tr style="display: none;">
                <td colspan="9">
                    <font size="5">物料明细</font>
                </td>
            </tr>
            <tr align="center">
                <td>
                    项号
                </td>
                <td>
                    物料编号
                </td>
               
                <td>
                    批次号
                </td>
                <td id="serial0">
                    序列号
                </td>
                <td id="qtya0">
                    数量
                </td>
               
                <td>管理号</td><td>数量</td><td>&nbsp;&nbsp;&nbsp;</td> <td>管理号</td><td>数量</td><td>&nbsp;&nbsp;&nbsp;</td> <td>管理号</td><td>数量</td><td>&nbsp;&nbsp;&nbsp;</td> <td>管理号</td><td>数量</td><td>&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <s:iterator value="%{#request.detailList}">
            <tr>
                <td>
                    <%=temp %>&nbsp;
                </td>
                <td>
                    <s:property value="%{materialNumber}"/>&nbsp;
                </td>
               
                <td>
                    <s:property value="%{receiveDetailBatchNumber}"/>&nbsp;
                </td>
                <td id="serial&lt;%=temp %>"&gt;
                    <s:property value="%{receiveDetailSerialNumber}"/>&nbsp;
                </td>
                <td id="qtya&lt;%=temp %>"&gt;
                    <s:property value="%{receiveDetailMaterialQty}"/>&nbsp;
                </td>
               
                <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;</td> <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;</td> <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;</td> <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;</td>
                <%temp++; %>
            </s:iterator>
        </table>
        <p></p>
        <table ;100%" border="0" cellpadding="0" cellspacing="0">
            <tr align="right">
                <td ;75%" align="right" colspan="15">
                    收货人:____________
                </td>
                <td align="right" colspan="2">
                    核实人:____________
                </td>
            </tr>
            <tr align="right">
                <td align="right" colspan="15">
                    日期:____________
                </td>
                <td align="right" colspan="2">
                    日期:____________
                </td>
            </tr>
            <tr align="right">
                <td colspan="17" align="right">
                    打印日期:<%=UtilDate.getDateFormatter() %>
                </td>
            </tr>
           
        </table>

       
<%=AddExcelbottom()%>
<%!
    private static String AddExcelHead(){
        StringBuffer sb = new StringBuffer();
        sb.append("&lt;html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
        sb.append(" <head>");
        sb.append(" <!--[if gte mso 9]><xml>");
        sb.append("<x:ExcelWorkbook>");
        sb.append("<x:ExcelWorksheets>");
        sb.append("<x:ExcelWorksheet>");
        sb.append("<x:Name></x:Name>");
        sb.append("<x:WorksheetOptions>");
        sb.append("<x:Print>");           
        sb.append("<x:ValidPrinterInfo />");
        sb.append(" </x:Print>");
        sb.append("</x:WorksheetOptions>");
        sb.append("</x:ExcelWorksheet>");
        sb.append("</x:ExcelWorksheets>");
        sb.append("</x:ExcelWorkbook>");
        sb.append("</xml>");
        sb.append("<![endif]-->");
        sb.append(" </head>");
        sb.append("<body>");
        return sb.toString();
    }

    private static String AddExcelbottom(){
        StringBuffer sb = new StringBuffer();
        sb.append("</body>");
        sb.append("</html>");
        return sb.toString();
    }
%&gt;
 
 中间红字部分为你要生成的Excel文件的内容部分。 具体添些什么由自己决定。

这直接是个Jsp页面,由地址栏打开这个页面,则直接提示用户下载或者打开Excel文件。