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. Advertising

  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. Advertising

  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. Advertising

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. Steve Kershaw
    Replies:
    2
    Views:
    516
    Cowboy \(Gregory A. Beamer\)
    Jul 16, 2007
  2. sridevi
    Replies:
    3
    Views:
    660
    sridevi
    May 11, 2005
  3. dd007
    Replies:
    0
    Views:
    391
    dd007
    May 24, 2006
  4. Replies:
    1
    Views:
    281
    Mirco Wahab
    Apr 17, 2007
  5. Katja
    Replies:
    1
    Views:
    196
Loading...

Share This Page