2

我的 ASP.NET C# 页面中有一个 Gridview。它有几列和一个图像列。我可以将整个列导出到 Excel 文件,但图像列是空白的。顺便说一句,我使用完整路径。

任何想法?

4

2 回答 2

2

在 default.aspx 中是(用于本地导出)

ImageUrl="http://localhost:4056/CSharp/banner.gif"
instead of ImageUrl="~/banner.gif"

或(用于远程导出)

http://your ip address here :port/foldername/filename
于 2012-11-26T12:19:39.480 回答
0

响应。清除();//这将清除任何标头或先前输出的响应 Response.Buffer = true; //确保同时渲染整个输出

    Response.ContentType = "application/vnd.ms-excel";
    StringWriter stringWriter = new StringWriter(); //System.IO namespace should be used

    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
    GridView2.GridLines = GridLines.Both;
    GridView2.RenderControl(htmlTextWriter);
    Response.Write(stringWriter.ToString());
    Response.End();
于 2010-05-21T06:47:28.120 回答