在页面的开始放上<%@ page contentType="application/vnd.ms-excel;charset=gb2312" %>替换掉<%@ page contentType="text/html; charset=GBK" %>就行了。

解决方案 »

  1.   

    先数据展现
    后点击按钮保存成excel文件
    怎样写代码
      

  2.   

    提示Internet 无法下载,
    请求站点不可用,找不到的
    错误信息
      

  3.   

    response.setContentType("application/octet-stream");
    response.addHeader("Content-Disposition", "attachment; filename=filename.xls");
    java.io.FileInputStream in = null;
    try
    {
        in = new java.io.FileInputStream(“realpath” +"filename.xls");
        byte[] buf = new byte[1024];
        int l = 0;    javax.servlet.ServletOutputStream sop = response.getOutputStream();    while ((l = in.read(buf, 0, 1024)) != -1)
        {
            sop.write(buf, 0, l);
        }
        sop.close();
        in.close();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    试试就知道了,好用