471,348 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

saving datatable to excel without popup

I'm using the following class to save data from database to an excel sheet. I
wonder how to do so without a popup box showing up (open, save)?Thanks
I want to save the exel sheet on the hard drive without letting the user see
this pop up.

public static void Export(DataTable dt, HttpResponse response)
// clean up response object
response.Charset = "";
response.Charset = "UTF-8";
response.ContentEncoding = System.Text.Encoding.Default;

// set response object's mime type
response.ContentType = "application/vnd.ms-excel";

System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);

DataGrid dg = new DataGrid();
dg.AllowPaging = false;
dg.AllowSorting = false;
dg.DataSource = dt;
dg.ShowHeader = true;
dg.HeaderStyle.BackColor = System.Drawing.Color.DarkGray;
dg.HeaderStyle.ForeColor = System.Drawing.Color.White;
dg.HeaderStyle.Font.Bold = true;
dg.AlternatingItemStyle.BackColor = System.Drawing.Color.LightGray;

Jul 25 '05 #1
0 3071

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by KeithRaginF | last post: by
6 posts views Thread by gane kol | last post: by
reply views Thread by viktor9990 | last post: by
1 post views Thread by Mark | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.