本文介绍了图像重叠在asp.net中导出到excel时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" height="66px" width="543px">
<columns>
<asp:BoundField DataField="MemberID" HeaderText="MemberID"
SortExpression="MemberID"/>
<asp:TemplateField HeaderText="Photo" ItemStyle-Width="150" ItemStyle-Height="170">
<itemtemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("MemberPhoto") %>' />
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "http://localhost:22749/DhaneraSite/" + Eval("MemberPhoto") %>' Height="100px" Width="100px" />
</itemtemplate>
<asp:BoundField DataField="MemberName" HeaderText="MemberName"
SortExpression="MemberName" />
<asp:BoundField DataField="MemberAddress" HeaderText="MemberAddress"
SortExpression="MemberAddress" />
<asp:BoundField DataField="ContactNo1" HeaderText="ContactNo1"
SortExpression="ContactNo1" />
<asp:BoundField DataField="ContactNo2" HeaderText="ContactNo2"
SortExpression="ContactNo2" />
<asp:BoundField DataField="EmailID" HeaderText="EmailID"
SortExpression="EmailID" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Occupation" HeaderText="Occupation"
SortExpression="Occupation" />
</columns>
private void BindData()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ToString());
string query = "SELECT * FROM AddressBook";
SqlDataAdapter ad = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
ad.Fill(ds, "AddressBook");
GridView1.DataSource = ds;
GridView1.DataBind();
}
private string ConnectionString
{
get { return @"Server=localhost;Database=Dhanera;Trusted_Connection=true"; }
}
protected void btnexcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=AddressBook.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
推荐答案
这篇关于图像重叠在asp.net中导出到excel时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!