有没有办法在Excel工作表中获取最大用户填充单元格而不传递范围或迭代每个Excel电子表格的最大单元格?
现在我有
Imports Excel = Microsoft.Office.Interop.Excel
Private Sub DoStuff()
Dim oApp As New Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
oWB = oApp.Workbooks.Open(txtExcel.Text)
oSheet = CType(oWB.ActiveSheet, Excel.Worksheet)
For Each iCount As Integer in oSheet.Cells.Rows.Count
'get cell text for every row in a specific column'
dim sCellText as string = oSheet.Cells(iCount, 1).toString
'do stuff'
Next
End Sub
现在oSheet.Cells.Rows.Count = 1048576,浏览工作表的数据不到1000行。
答案 0 :(得分:1)
尝试oSheet.UsedRange
在这里,您可以检查上面返回的Range
实例中的列,以找出特定列中填充的单元格。
OR
WorksheetFunction.CountA(range("A1:A20000"))