我有一个包含一些数据的网格,对于一列,我添加了图像以更好地向用户展示。现在我有一个导出选项,可以将网格导出到 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();