[英]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.