Exporting in SharePoint using Excel or Document APIs

[Infragistics] Murtaza Abdeali / Wednesday, July 29, 2009

Recently a customer reported an issue with exporting the WebGrid in one of their SharePoint WebParts to Excel. As soon as the user exported WebGrid's data, the entire SharePoint page became unresponsive. All buttons and checkbox controls that were on the page didn’t respond when the user clicked on them once an export operation had happened on the page. As SharePoint developers know this well, debugging server-side code is not an easy task, and this issue seemed to be a client issue so it became extremely difficult to track down. The customer had reported this initially through our support and it has been looked into by development, but due to its nature we were not able to get to the bottom of it. Basically, we were reaching a point to make a final call on this as we couldn’t figure out if it was an issue on our part or had someting to do with SharePoint.

As a last resort, I wanted to see if anyone else ran into this issue, so I pinged my best friend, Google. It took me a while initially to explain it exactly what I was really looking for, but going back and forth a couple of times it came back with a search result that explained everything.


http://msmvps.com/blogs/laflour/archive/2008/06/06/page-events-stop-working-after-using-output-stream-for-binary-download.aspx


So, the issue happens anytime you do a binary write on a page that downloads a document on the client. Since there is no full page postback, the SharePoint page unregisters all the default html control events, but never hooks them back and the page is dead. Using the solution provided in the post, we were able to work around the problem for the customer.


Thanks to Michael Nemtsev for posting the solution, and to Google for making it easier to find :).