By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

How to delete an Excel worksheet by using ASP.NET?

P: n/a

Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi

You can use
File.Delete(@"c:\test.txt");
But ASP.NET Account should have write access to delete file.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

HTH
Ravikanth[MVP]

"Shao Yong" wrote:

Nov 18 '05 #2

P: n/a
Any excel worksheet is simply a file, so

[VB]
System.IO.File.Delete("C:\Book1.xls")
[C#]
System.IO.File.Delete(@"C:\Book1.xls");

will do.

The account with which the worker process is running should have modify
rights on the file. Usually, the worker process runs under the
ASPNET_MachineName account or in Windows 2003 under NETWORK SERVICE account.
Alternativelly, impersonate a user that has modify rights on the file. See:

http://support.microsoft.com/?kbid=306158

Greetings
Martin
"Shao Yong" <an*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...


Nov 18 '05 #3

P: n/a
Sorry, i mean how to delete the sheet of an Excel document, not the file itself.
Nov 18 '05 #4

P: n/a
You
"Shao Yong" <an*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
Sorry, i mean how to delete the sheet of an Excel document, not the file

itself.

Nov 18 '05 #5

P: n/a
Hi, Shao Yong,

You need to open the workbook with com automation and remove the worksheet
using the Excel object model.

Hope this helps
Martin
"Shao Yong" <an*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
Sorry, i mean how to delete the sheet of an Excel document, not the file

itself.

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.