Hi,
I have project in VB.net version 1.1.I want to export Data from data set to excel.My data set contains to tables and i want them to be export in two different worksheet of single excel . Please Help
thanks,
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Feb 27, 2011, 12:42 PM
SanthonabinPosted Feb 25, 2011, 5:32 AM
Thanks u Very much . Surely i ll follow this..
Suthish NairPosted Feb 25, 2011, 5:02 AM
The usage of more Response.Write is not good in web applications.
Build your string using StringBuilder class and the call the Response.Write once.
SanthonabinPosted Feb 25, 2011, 4:37 AM
try this...
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = GetData();
string attachment = "attachment; filename=ExportTable.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(tab + dc.ColumnName);
tab = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
tab = "";
for (i = 0; i < dt.Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
}
Manikavelu VelayuthamPosted Feb 25, 2011, 4:13 AM
Hope this article helps you.