Click here to Skip to main content
15,889,651 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help me iam getting stack overflow exeception , while my solution build successfully , but it threw the stack overflow error Pin
johannesnestler1-Jul-09 5:32
johannesnestler1-Jul-09 5:32 
QuestionItem collection cannot be modified when datasource property is set Pin
Rahul DSG16-Jun-09 21:05
Rahul DSG16-Jun-09 21:05 
AnswerRe: Item collection cannot be modified when datasource property is set Pin
himanshu256116-Jun-09 21:34
himanshu256116-Jun-09 21:34 
AnswerRe: Item collection cannot be modified when datasource property is set Pin
Morteza Karimian Kelishadrokhi29-Jul-11 3:45
Morteza Karimian Kelishadrokhi29-Jul-11 3:45 
AnswerRe: Item collection cannot be modified when datasource property is set Pin
Morteza Karimian Kelishadrokhi29-Jul-11 8:41
Morteza Karimian Kelishadrokhi29-Jul-11 8:41 
QuestionExport to Excel in not working Pin
binod kumar16-Jun-09 20:48
binod kumar16-Jun-09 20:48 
AnswerRe: Export to Excel in not working Pin
Ashfield16-Jun-09 20:52
Ashfield16-Jun-09 20:52 
AnswerRe: Export to Excel in not working Pin
moon_stick17-Jun-09 1:28
moon_stick17-Jun-09 1:28 
I assume that this is being done in ASP.NET??

There's a few things you need to do to ensure that the application works. Note that the official MS line is that Excel is not a server component so they don't provide any support in that respect.

First things first - you'll need to have Excel installed on the server along with the interop assemblies.

Secondly, you need to ensure that the DCOM settings for Excel allow it to be launched from within IIS. You'll need to know what identity your web application will launch Excel as (it's usually NETWORK SERVICE, ASPNET or IUSR_<machinename> depending on your settings and version of IIS). To do this:

Start menu -> Run -> dcomcnfg.exe
Component Services -> Computers -> My Computer -> DCOM Config
Microsoft Excel Application -> Right Click, Properties -> Security Tab

From this tab you need to change the launch, access and configuration permissions to allow full and remote access to the user account you located above.

Next you'll need to do:
Properties -> Identity
select 'Interactive User'.

Finally you'll need to ensure that the webpage launching excel is correctly configured. The interop component expects to be run in a single thread apartment (STA) but ASP.NET defaults to multiple threads (MTA). You can force the use of an STA by including

AspCompat="true"

in the page directive header.

Finally you'll need to modify your web.config file to include a

identity impersonate="true"

section under system.web.


From the way you've written this code, I think you'll end up running into a problem that the instance of excel remains in memory after each export is performed. I don't have time to go into the detail but the problem is that you're not cleaning up objects once they've been disposed of. Note that when you create the export you're actually creating a number of objects (Application, Workbook, Worksheet, Range - at the very least) and all these need cleaning up.

There's articles out there on the web that will explain how to do this though it might take you a bit of trial and error.

Hope that helps!

It definitely isn't definatley

QuestionAny UI Control like gmail's "to:" textbox? [modified] Pin
Quake2Player16-Jun-09 19:15
Quake2Player16-Jun-09 19:15 
AnswerRe: Any UI Control like gmail's "to:" textbox? Pin
Isaac Gordon16-Jun-09 20:07
Isaac Gordon16-Jun-09 20:07 
QuestionWebcam QR barcode decoder problem [modified] Pin
S K Y16-Jun-09 19:01
S K Y16-Jun-09 19:01 
QuestionHow to hook Adobe reader document using c#? Pin
svt gdwl16-Jun-09 18:33
svt gdwl16-Jun-09 18:33 
QuestionPutting a line of numbers (from a text file) into an array Pin
70superbee16-Jun-09 15:05
70superbee16-Jun-09 15:05 
AnswerRe: Putting a line of numbers (from a text file) into an array Pin
Not Active16-Jun-09 15:56
mentorNot Active16-Jun-09 15:56 
Question"Out of memory exception when loading image with bitmap Pin
Casper Hansen16-Jun-09 10:11
Casper Hansen16-Jun-09 10:11 
AnswerRe: "Out of memory exception when loading image with bitmap Pin
Luc Pattyn16-Jun-09 11:20
sitebuilderLuc Pattyn16-Jun-09 11:20 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Casper Hansen17-Jun-09 9:13
Casper Hansen17-Jun-09 9:13 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Luc Pattyn17-Jun-09 9:33
sitebuilderLuc Pattyn17-Jun-09 9:33 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Casper Hansen19-Jun-09 3:54
Casper Hansen19-Jun-09 3:54 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Luc Pattyn19-Jun-09 4:18
sitebuilderLuc Pattyn19-Jun-09 4:18 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Revathij25-Jun-09 22:28
Revathij25-Jun-09 22:28 
GeneralRe: "Out of memory exception when loading image with bitmap Pin
Luc Pattyn25-Jun-09 23:39
sitebuilderLuc Pattyn25-Jun-09 23:39 
QuestionGetting all the nodes in a treeview Pin
Quake2Player16-Jun-09 7:16
Quake2Player16-Jun-09 7:16 
AnswerRe: Getting all the nodes in a treeview Pin
Dave Kreskowiak16-Jun-09 8:16
mveDave Kreskowiak16-Jun-09 8:16 
AnswerRe: Getting all the nodes in a treeview Pin
Eslam Afifi16-Jun-09 8:26
Eslam Afifi16-Jun-09 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.