Home » excel » classic asp delete rows and columns from an excel file

classic asp delete rows and columns from an excel file

Posted by: admin May 14, 2020 Leave a comment


how can I remove specific rows and columns from an excel file using only classic ASP? For example, given the excel file

col1  col2  col3
one   two   three
four  five  six

I want to be able to programmatically delete the first row and second column to produce

one   three
four  six


How to&Answers:

You can try using an Excel.Application object. For example:

dim oExcel, oWkBk  
set oExcel = CreateObject( "Excel.Application" )
oExcel.Visible = false
oExcel.DisplayAlerts = false
set oWkBk = oExcel.WorkBooks.Open( "C:\path\file.xls" )

You can then delete any individual cells with:

oExcel.Cells( 1, 1 ).Delete

Or entire rows/columns with:


To check if a cell is empty use:

if isEmpty(oExcel.Cells(1,1)) then ...

Finally, cleanup:

set oWkBk = nothing
set oExcel = nothing

For more info, try Googling things like “excel application object vbscript.” You can find many examples. Unfortunately, I’ve found it impossible to find a complete reference.