excel文件中下载的gridview数据不包含文件中的单元格边框 [英] Downloaded gridview data in excel file does n't contain cell border in file

查看:74
本文介绍了excel文件中下载的gridview数据不包含文件中的单元格边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我在excel文件中下载gridview数据我的网格包含网格线,但下载excel文件后没有显示单元格边框。



我尝试了什么:



我试过用



每个(gridview1.cell中的Tablecell单元格)

{Cell.border style = color.black;

}

喜欢这个

Hi friends,

I am downloading gridview data in excel file my grid contains gridlines but after downloading excel file not displaying cell borders.

What I have tried:

I tried with

For each(Tablecell cell in gridview1.cell..)
{Cell.border style=color.black;
}
Like this

推荐答案

我猜你是在设置边框后设置边框样式。



My guess is that you're setting the border style AFTER you've set the border itself.

foreach (TableCell cell in row.Cells)
{
    cell.BorderStyle = grdMaterials.BorderStyle; // <--- moved this line out of the following if condition
    if (row.RowIndex % 2 == 0)
    {
        cell.BackColor = grdMaterials.AlternatingRowStyle.BackColor;
        cell.BorderColor = Color.Black;
        // cell.BorderStyle = grdMaterials.BorderStyle;
    }
    else
    {
       cell.BackColor = grdMaterials.RowStyle.BackColor;
    }
    cell.CssClass = "textmode";
}


这篇关于excel文件中下载的gridview数据不包含文件中的单元格边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆