Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends ,

I am extracting the data from database to EXCEL sheet . the excel sheet carry's more than 40000 rows and 90 columns . look at the below code which i have used in my website ,

C#
string fileName = "attachment;filename= ArchivalReportOn_" +  DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xls";
                    Response.Clear();
                    Response.AddHeader("content-disposition", fileName);
                    Response.Charset = "";
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.ContentType = "application/ms-excel";
                    GridView gridview1 = new GridView();
                    gridview1.DataSource = dt;
                    gridview1.HeaderStyle.CssClass = "gridHeader";
                    gridview1.HeaderStyle.BackColor = System.Drawing.Color.Red;
                    gridview1.HeaderStyle.ForeColor = System.Drawing.Color.White;
                    gridview1.DataBind();
                    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);                   
                    gridview1.RenderControl(htmlWrite);
                    string s_styleInfo = @"<style> td { mso-number-format:""" + "\\@" + @"""; }</style>";
                    string s_excel = stringWrite.ToString();
                    Response.Write(s_styleInfo + s_excel);                   
                    Response.End();  


while retrieving data i am getting the error "Problem Loading File and Missing File like .Css" , So can any one suggest me how to fix that error .
Posted
Updated 8-Sep-11 20:27pm
v3
Comments
Uday P.Singh 8-Sep-11 3:32am    
use code block for coding section

1 solution

There are two possibilities for this problem.

1. Either the CSS file is missing and your system is serving up a 404 page (if you've configured it) so the browser is complaining that it's not a CSS file.

2. It could be that you have a server configuration issue. If it's a new installation of WAMP, this is pretty unlikely.

Just to validate the stuff, you can view the source in any browser.

On browsing CSS file, if it takes you to another file that means you haven't linked it properly. You may be better off using an absolute path (from your webroot) rather than a relative path.
 
Share this answer
 
Comments
Uday P.Singh 8-Sep-11 5:57am    
Do you think OP is using Apache?
SARAVANAKUMAR.M 9-Sep-11 2:32am    
Thanks for your information GanesanSenthilvel , I am getting this error if i download the data which contains more than 12000 rows , if i download less than 12,000 rows means its not showing that error.
In my excel sheet the output will be more than 30,000 rows with 80 columns that is problem it seems .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900