Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在导出到excel时删除网格中的图像_C#_Asp.net - Fatal编程技术网

C# 如何在导出到excel时删除网格中的图像

C# 如何在导出到excel时删除网格中的图像,c#,asp.net,C#,Asp.net,我有一个包含一些数据的网格,我为其中一列添加了图像,以提高用户的可视性。现在我有了一个导出选项,可以将网格导出到excel工作表。在excel中,我得到未找到图像图标。我不想在excel工作表中向用户显示图像。有什么帮助吗 Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "123.

我有一个包含一些数据的网格,我为其中一列添加了图像,以提高用户的可视性。现在我有了一个导出选项,可以将网格导出到excel工作表。在excel中,我得到未找到图像图标。我不想在excel工作表中向用户显示图像。有什么帮助吗

Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "123.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// gdAclog.AllowPaging = false;
// gdAclog.DataBind();
//Change the Header Row back to white color
gdAclog.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < gdAclog.HeaderRow.Cells.Count; i++)
{
    gdAclog.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
}
int j = 1;
//This loop is used to apply stlye to cells based on particular row
foreach (GridViewRow gvrow in gdAclog.Rows)
{
    gvrow.BackColor = Color.White;
    if (j <= gdAclog.Rows.Count)
    {
        if (j % 2 != 0)
        {
            for (int k = 0; k < gvrow.Cells.Count; k++)
            {
                gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
            }
        }
    }
    j++;
}
gdAclog.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
Response.ClearContent();
Response.Buffer=true;
AddHeader(“内容处置”,string.Format(“附件;文件名={0}”,“123.xls”);
Response.ContentType=“应用程序/ms excel”;
StringWriter sw=新的StringWriter();
HtmlTextWriter htw=新的HtmlTextWriter(sw);
//gdAclog.allowpage=false;
//gdaclocg.DataBind();
//将标题行更改回白色
gdAclog.HeaderRow.Style.Add(“背景色”和“#FFFFFF”);
//将stlye应用于gridview标题单元格
for(int i=0;i如果(j如果您无论如何都不想显示它,您可以在所有单元格中循环并检查单元格内容是否为图片。
if(Table.cell(row,col).GetType().Equals(“msoPicture”))
然后将单元格内容设置为null或任何您想要的值。对于图片,如果您仍然需要它,您可以将其保存在临时文件中或复制到剪贴板(错误做法)。

您的图像在哪个单元格中?5项模板中的图像