以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  excel报表中插入或删除多行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=123567)

--  作者:一笑
--  发布时间:2018/8/17 18:41:00
--  excel报表中插入或删除多行
帮助文档中Insert和RemoveAt插入或删除单行,如:
Sheet.Rows.RemoveAt(0)
可否插入或删除多行?谢谢!

--  作者:有点蓝
--  发布时间:2018/8/17 20:30:00
--  
循环

for i as integer = 1 to 100
Sheet.Rows.RemoveAt(0)
next


Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\Report.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Rows("1:3")\'选定多行
Rg.Delete(MSExcel.XlDirection.xlUp) \'下面的单元格上移
Rg = Ws.Columns("D:F")  \'选定多列
Rg.Delete(MSExcel.XlDirection.xlToLeft) \'右面的单元格左移
App.Visible = True