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

G

Guest

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]
 
M

Martin Dechev

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
 
M

Martin Dechev

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 said:
Sorry, i mean how to delete the sheet of an Excel document, not the file
itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top