簡體   English   中英

經典的ASP從Excel文件中刪除行和列

[英]classic asp delete rows and columns from an excel file

如何僅使用經典ASP從excel文件中刪除特定的行和列? 例如,給定excel文件

col1  col2  col3
one   two   three
four  five  six

我希望能夠以編程方式刪除第一行和第二列以產生

one   three
four  six

謝謝!

您可以嘗試使用Excel.Application對象。 例如:

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

然后,您可以使用以下方法刪除任何單個單元格:

oExcel.Cells( 1, 1 ).Delete

或整個行/列包含:

oExcel.Cells(1,1).EntireColumn.Delete
oExcel.Cells(1,1).EntireRow.Delete

要檢查單元格是否為空,請使用:

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

最后,清理:

oWkBk.Close()
oExcel.Quit()
set oWkBk = nothing
set oExcel = nothing

有關更多信息,請嘗試使用Google搜索功能,例如“ excel應用程序對象vbscript”。 您可以找到許多示例。 不幸的是,我發現找不到完整的參考資料。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM