我想在asp.net上导出到excel? [英] I want to export to excel on asp.net?
本文介绍了我想在asp.net上导出到excel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将网格导出为excel。这就是我在做的...
将myHtmlWriter变暗为HtmlTextWriter
myHtmlWriter = New HtmlTextWriter(myStringWriter)
我的问题是,上面的方法将网格导出到默认的Excel工作表。假设我的项目中有一个excel文件/电子表格作为'myexcel.xls'。我想在这个Excel工作表上导出我的网格,即(myexcel.xls)。有没有办法做到这一点?感谢您的帮助。
I am trying to export a grid to excel. This is how I am doing...
Dim myHtmlWriter As HtmlTextWriter
myHtmlWriter = New HtmlTextWriter(myStringWriter)
My question is, the above method exports the grid to default excel sheet. Suppose I have a excel file/spreadsheet sitting in my project as 'myexcel.xls'. I would like to export my grid on this excel sheet i.e.(myexcel.xls). Is there a way to do this? I appreciate your help.
推荐答案
尝试
将Gridview数据导出到ASP.NET中的Excel [ ^ ]
使用C#和VB格式化在ASP.Net中将GridView导出到Excel .Net [ ^ ]
[ASP.NET编程]
使用ASP.Net C将Gridview导出到Excel#
[ ^ ]
Try
Export Gridview Data to Excel in ASP.NET[^]
Export GridView to Excel in ASP.Net with Formatting using C# and VB.Net[^]
[ASP.NET Programming]
Export Gridview to Excel Using ASP.Net C#
[^]
从asp.net c中的网格视图导出到excel#
代码: -
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
string strConnString = ConfigurationManager.ConnectionStrings [" constr"]。ConnectionString;
使用(SqlConnection con = new SqlConnection(strConnString))
{
using(SqlCommand cmd = new SqlCommand(" SELECT * FROM Customers"))
{
使用(SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
使用(DataTable dt = new DataTable())
{
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
}
}
Export to excel from grid view in asp.net c#
Code:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
}
}
这篇关于我想在asp.net上导出到excel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文