?
Solved

ASP.Net Exporting dataset/repeater/html to excel

Posted on 2004-12-01
7
Medium Priority
?
394 Views
Last Modified: 2012-08-14
I have an application that exports any of the above types to excel using    
response.ContentType = "application/vnd.ms-excel"

Recently the app stopped working, the excel report page flashes on the screen and then disappears.  Is anyone else running into this with IE or IIS upgrades?  These were originally built on Win2000Server recently migrated to Win2003Server.
0
Comment
Question by:Nobletucky2004
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:AgentSmith007
ID: 12716978
I've recently experienced a similar issue, however I couldn't attribute it to the web server. I found an inconsistency with WinXP SP2 browsers having this issue. I forgot exactly what I was doing, but it was something like redirecting to a different file and then firing a window.close() from javascript. It worked all the time before and then stopped working on XP SP2 machines. I had to add some workaround javascript. I don't know if this is what's happening to you, just sharing my 2 cents. Can you post some more of your sample code?
0
 

Author Comment

by:Nobletucky2004
ID: 12717031
   response.Clear();
    response.Charset = "";
    //set the response mime type for excel
    response.ContentType = "application/vnd.ms-excel";
    //create a string writer
    System.IO.StringWriter stringWrite  = new System.IO.StringWriter();
    //create an htmltextwriter which uses the stringwriter
    System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
    //instantiate a datagrid
    DataGrid dg = new DataGrid();
    //set the datagrid datasource to the dataset passed in
    dg.DataSource = ds.Tables[0];
    //bind the datagrid
    dg.DataBind();
    //tell the datagrid to render itself to our htmltextwriter
    dg.RenderControl(htmlWrite);
    //all that//s left is to output the html
    response.Write(stringWrite.ToString());
    response.End();
0
 

Author Comment

by:Nobletucky2004
ID: 12717071
what type of JavaScript workaround did you use to alleviate this problem?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
AgentSmith007 earned 1500 total points
ID: 12717129
The case I had is that I was popping up a window from the existing window (after some browser detection was done) and i was initially doing this:

window.open(...);
top.close();

When this stopped working I had to do this:

window.open(...);

function fClose(){
   top.close();
}

then from the window that popped up I did a:

window.opener.fClose();

This doesn't seem to be your issue though. I'm gonna refer this question to a friend of mine that's more .net savvy
0
 

Author Comment

by:Nobletucky2004
ID: 12717155
Could this have something to do with a setting that is dealing with Trusted Sites.  It seems that when the URL is added to Trusted Sites the files will open in excel, but that presents an issue with having to figure out if users have the URL set in trusted sites, that is rather messy.
0
 
LVL 9

Expert Comment

by:AgentSmith007
ID: 12717183
Interesting. Is you IE security set beyond default? Try going into Tools -> Internet Options -> Security and setting the internet zone to the default setting and see what happens.
0
 

Author Comment

by:Nobletucky2004
ID: 12717282
yea, most users that are testing this now have default security settings post an SP2 update.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Screencast - Getting to Know the Pipeline

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question