[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
This course will introduce you to C++ 11 and teach you about syntax fundamentals.
dt = datatable.GetAllData();//your datatable
string attachment = "attachment; filename=excelfile.xls";
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dt.Columns)
Response.Write(tab + dc.ColumnName);
tab = "\t";
foreach (DataRow dr in dt.Rows)
tab = "";
for (i = 0; i < dt.Columns.Count; i++)
Response.Write(tab + dr[i].ToString());
tab = "\t";
Open in new window
using (SqlCommand cmd = new SqlCommand(query))
using (SqlDataAdapter dataadapter = new SqlDataAdapter())
cmd.Connection = con;
dataadapter.SelectCommand = cmd;
using (DataSet ds = new DataSet())
ds.Tables.TableName = "A";
ds.Tables.TableName = "B";
ds.Tables.TableName = "C"; -- example
using (XLWorkbook wb = new XLWorkbook())
foreach (DataTable dt in ds.Tables)
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
using (MemoryStream PawanMemoryStream = new MemoryStream())
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.