解决方案 »

  1.   

    使用第三方组件导出..而不是直接拿html中的数据.. 否则你有分页你如何导出??百度搜索 myxls  或者 npoi直接循环结果集写入数据就行了..
      

  2.   

    你这个Repeater 是在后台做了数据绑定,你可以直接在后台把数据导出来。
     protected void Button1_Click(object sender, EventArgs e)
        {
            string sql = "select id,code from eban_summary ";
            string[] arr = { "编号", "设备号" };
            string file = uploadPathCreate("数据导出");
            if (!Directory.Exists(file))
            {
                Directory.CreateDirectory(file);
            }
            DataSet ds = Comm.BLLBase.DBHelper.ExecuteDataSet(sql);
            string filename = Comm.ExcelUtils.ExportToExcel(ds, file, ".xls", arr, "");
            Response.Redirect(file + filename);
        }
        public string uploadPaths(string type)
        {
            return "~\\Upfile\\Excel\\" + type + "\\" + getDateString() + "\\";
        }
        public string uploadPathCreate(string type)
        {
            return HttpContext.Current.Request.PhysicalApplicationPath + @"Upfile\Excel\" + type + "\\" + getDateString() + "\\";
        }
        public string getDateString()
        {
            return string.Format("" + DateTime.Now.ToShortDateString() + "", "yyyy-mm-dd").Replace("-", "").Replace("/", "").Replace(".", "");
        }
    诸如此类的导出方法,网上还是有很多案例的
      

  3.   

    楼上正解, 返回一个excel 响应就行,通过excel  Com组件
      

  4.   

    自己用组件导出来呀,用html导出格式会比较乱
      

  5.   

    将数据集绑定到Repeater上面,然后又在上面去找 。何必呢直接在数据集上面导
      

  6.   

    不通过repeater、datalist之类的数据绑定控件导出,直接查询导出,输出excel类型文件,或者通过第三方组件如NPOI导出
      

  7.   

    把Sql Server数据导出到Excel
       private void btn_Excel_Click(object sender, EventArgs e)
            {
                if (dgv_Info.Rows.Count == 0)//判断是否有数据
                    return;//返回
                Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();//实例化Excel对象
                excel.Application.Workbooks.Add(true);//在Excel中添加一个工作簿
                excel.Visible = true;//设置Excel显示
                //生成字段名称
                for (int i = 0; i < dgv_Info.ColumnCount; i++)
                {
                    excel.Cells[1, i + 1] = dgv_Info.Columns[i].HeaderText;//将数据表格控件中的列表头填充到Excel中
                }
                //填充数据
                for (int i = 0; i < dgv_Info.RowCount - 1; i++)//遍历数据表格控件的所有行
                {
                    for (int j = 0; j < dgv_Info.ColumnCount; j++)//遍历数据表格控件的所有列
                    {
                        if (dgv_Info[j, i].ValueType == typeof(string))//判断遍历到的数据是否是字符串类型
                        {
                            excel.Cells[i + 2, j + 1] = "'" + dgv_Info[j, i].Value.ToString();//填充Excel表格
                        }
                        else
                        {
                            excel.Cells[i + 2, j + 1] = dgv_Info[j, i].Value.ToString();//填充Excel表格
                        }
                    }
                }
            }