none
About Excel Deletion RRS feed

  • Question

  • Hi,....

     

         I copied records from excel to datatable and i deleted a record in datatable(Since Excel cannot support Delete statement ),

    but after reading rows from datatable and stored in excel it will work ,

        But the problem is it appended the rows with already existing rows

        Is there any other way to insert updated rows from datatable to excel sheet

    Tuesday, January 31, 2012 4:51 AM

Answers

  • Yes, Delete is not supported in JET for Excel file and Text file.

    You need to DROP WorkSheet which deletes all the data in a worksheet than Create again and Add all Rows to the Sheet.


    Lingaraj Mishra
    Tuesday, January 31, 2012 8:24 AM
  • As per Lingaraj Mishra in regards to dropping the worksheet, you may find out that the DROP TABLE Sheet name may not actually remove the worksheet but instead clear the worksheet which is what I have done in the past and retried this today under MS-Excel 2007 on a pre 2007 file using a basic connection i.e.

    provider=Microsoft.Jet.OLEDB.4.0;Data Source=Demo1.xls;Extended Properties="Excel 8.0; HDR=Yes;"

    So if that is the case there is no need to create the sheet again as it is still there.


    KSG
    Tuesday, January 31, 2012 8:42 PM

All replies

  • Yes, Delete is not supported in JET for Excel file and Text file.

    You need to DROP WorkSheet which deletes all the data in a worksheet than Create again and Add all Rows to the Sheet.


    Lingaraj Mishra
    Tuesday, January 31, 2012 8:24 AM
  • As per Lingaraj Mishra in regards to dropping the worksheet, you may find out that the DROP TABLE Sheet name may not actually remove the worksheet but instead clear the worksheet which is what I have done in the past and retried this today under MS-Excel 2007 on a pre 2007 file using a basic connection i.e.

    provider=Microsoft.Jet.OLEDB.4.0;Data Source=Demo1.xls;Extended Properties="Excel 8.0; HDR=Yes;"

    So if that is the case there is no need to create the sheet again as it is still there.


    KSG
    Tuesday, January 31, 2012 8:42 PM