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

Discussion in 'ASP .Net' started by =?Utf-8?B?U2hhbyBZb25n?=, May 10, 2004.

  1.  
    =?Utf-8?B?U2hhbyBZb25n?=, May 10, 2004
    #1
    1. Advertisements

  2. 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:

    >
    >
     
    =?Utf-8?B?UmF2aWthbnRoW01WUF0=?=, May 10, 2004
    #2
    1. Advertisements

  3. 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" <> wrote in message
    news:...
    >
     
    Martin Dechev, May 10, 2004
    #3
  4. Sorry, i mean how to delete the sheet of an Excel document, not the file itself.
     
    =?Utf-8?B?U2hhbyBZb25n?=, May 11, 2004
    #4
  5. You
    "Shao Yong" <> wrote in message
    news:...
    > Sorry, i mean how to delete the sheet of an Excel document, not the file

    itself.
     
    Martin Dechev, May 12, 2004
    #5
  6. 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" <> wrote in message
    news:...
    > Sorry, i mean how to delete the sheet of an Excel document, not the file

    itself.
     
    Martin Dechev, May 12, 2004
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. harshan
    Replies:
    0
    Views:
    613
    harshan
    Jul 20, 2004
  2. Steve Kershaw
    Replies:
    2
    Views:
    687
    Cowboy \(Gregory A. Beamer\)
    Jul 16, 2007
  3. Tabo

    Create Excel worksheet by using web service

    Tabo, Oct 14, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    401
    Dino Chiesa [Microsoft]
    Oct 16, 2003
  4. sridevi
    Replies:
    3
    Views:
    851
    sridevi
    May 11, 2005
  5. magix

    ASP Excel worksheet

    magix, Jul 27, 2006, in forum: ASP General
    Replies:
    5
    Views:
    318
    Mike Brind
    Jul 27, 2006
  6. dd007
    Replies:
    0
    Views:
    698
    dd007
    May 24, 2006
  7. Replies:
    1
    Views:
    473
    Mirco Wahab
    Apr 17, 2007
  8. Katja
    Replies:
    1
    Views:
    345
Loading...