Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 28058

downloading .xls file

$
0
0
Hi, I have asp.net site where I can create and download .xls file. At develepment server everthing works fine, but after deploying nothing works. Is in IIS 7 any options which can prevent this functionality ?? I have no idea what is wrong so here is my code - might be helpfull: SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString); SqlCommand comm = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); comm.Connection = conn; comm.CommandText = "SELECT * FROM [Users]"; try { comm.Parameters.Clear(); conn.Open(); da.SelectCommand = comm; da.Fill(dt); conn.Close(); } catch { conn.Close(); Response.Redirect("~/error.aspx"); } string attachment = "attachment; filename=Users.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/vnd.ms-excel"; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); 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

Viewing all articles
Browse latest Browse all 28058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>