Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A problem creating Excel object 1

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
US
I'm tying to create new Excel Object;
Excel.Application Myexcel = new Excel.Application();
But it gives error:
Exception Details: System.UnauthorizedAccessException: Access is denied.

I'm made the reference to Excel.dll and gave the permission and it still gives error.....

How can I solve this?
 
One method is to use javacript, e.g.,

<script language=&quot;JavaScript&quot;>
function startExcel(strFile){
var myApp = new ActiveXObject(&quot;Excel.Application&quot;);
if (myApp != null){
myApp.Workbooks.Open(strFile);
myApp.Visible = true;
}
}
</script>

The add a href to open Excel file:

<a href=&quot;javascript:startExcel('XL3034.xls')&quot;>Open Excel File</a>
 
Plato: Couple of articles that might help (in case you didn't come across them):

Read Excel files from ASP.NET

Using Excel Spreadsheets as a DataSource

Security settings-From ASP.net to run Excel application

ASP.NET: Display data from an Excel Spreadsheet

Post back and let us know if you crack this one Plato.
 
Thank you for the links.
The third link doesn't exists and 3 other links use OleDB adapter to select data from Excel(by using select statement) but I want to open excel and read each cell at a time.
I have to use this way cause &quot;select&quot; doesnt help in some cases....

Any other suggestions.
Thanks again
 
Finally I managed to Create Excel object from asp.net. But I had to create a custom asp.net account and then I had to restart iis(I did that for my local server) .
Do I have to create custom asp.net account for my remote server and restart iis - it seems very inconvinient. Is there is another way to do that(to make Excel 'problem' work)? Why do I have to create custom asp.net?

If anybody can explain in more details why these problems(with excel) are happening and how to get around - I would greatly appreciate that?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top