本帖最后由 zyydj_10 于 2011-11-18 18:26:15 编辑

解决方案 »

  1.   

    检查一下你的class="table"样式表,你在网页上看到的gridview如果没有框框的话,导出来的就没有了
    要么在你的Export方法中给gridview加上带框框的样式表
      

  2.   

    导出EXCEL时最好使用普通的边框样式,有一些GridView的边框样式EXCEL是取不到的,你换换边框样式就会有惊喜的发现的呵呵。
      

  3.   

    要加边框需要写代码控制excel
      

  4.   

    http://www.cnblogs.com/homezzm/archive/2009/12/04/1616668.html
      

  5.   

    我看别人写的也没有加边框的代码来控制excel啊,为什么我的要加上呢,而且我的样式也不复杂啊,基本上也没有什么别的样式。
      

  6.   

        /// <summary>
        /// 导出gridview列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Export_Common(object sender,CommandEventArgs e)
        {
            string strCommandName = e.CommandName;
            if (strCommandName=="Export")
            {
                if (this.gvwDataList.Rows.Count==0)
                {
                    Alert("当前无数据导出!");
                    return;
                }
                int nDelIndex = this.gvwDataList.Columns.Count - 1;// 删除列
                int nAllot = nDelIndex - 1;// 分配列
                this.gvwDataList.Columns[nDelIndex].Visible = false;// 隐藏删除列
                this.gvwDataList.Columns[nAllot].Visible = false;// 隐藏分配列
                // 显示边框
                for (int i = 0; i < nAllot; i++)
                {
                    this.gvwDataList.Columns[i].HeaderStyle.BorderWidth = 1;
                    this.gvwDataList.Columns[i].ItemStyle.BorderWidth = 1;
                }  
                // 导出Excel
                CommonConst.ControlExport(this.gvwDataList,"申请记录_"+DateTime.Now.ToString("yyyyMMddHHmmss"));
                this.gvwDataList.Columns[nDelIndex].Visible = false;// 显示删除列
                this.gvwDataList.Columns[nAllot].Visible = false;// 显示分配列
                // 隐藏边框
                for (int i = 0; i < nAllot; i++)
                {
                    this.gvwDataList.Columns[i].HeaderStyle.BorderWidth = 0;
                    this.gvwDataList.Columns[i].ItemStyle.BorderWidth = 0;
                }
            }
        }