我刚刚开始使用VB.net,在我的应用程序中我需要在excel文件中使用确切数量的已用行我看了一下这篇文章 使用vb.net读取行数 我尝试了所有答案,但我'我从来没有得到确切的行数,我也在一些网站尝试过其他代码,但也没有!任何人都可以帮助我PLZ
你好,我实际上使用SQL SERVER 2008我试过这段代码
Imports System.Diagnostics.Process
Imports System.IO
Imports System.Data.DataTable
Imports Microsoft.Office.Tools
Imports Excel
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim selectedFile As String = String.Empty
OpenFileDialog1.ShowDialog()
selectedFile = OpenFileDialog1.FileName
If (selectedFile IsNot Nothing) Then
ListBox1.Items.Add(selectedFile)
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim fullPath As String
Dim fileResult As String
Dim numRow As Integer
fullPath = Path.GetFullPath(ListBox1.SelectedItem)
fileResult = Path.GetFileName(fullPath)
Dim file_count As Integer = File.ReadAllLines(fullPath).Length
MsgBox(file_count)
Run Code Online (Sandbox Code Playgroud)
但再次计数不正确,我真的不知道为什么!
我希望使用Microsoft.Office.Interop.Excel和vb.net 2010将常用工作表导入到sql 2008中的例程使用的行仅用于:
usedRowsCount = xlWorksheet.UsedRange.Rows.Count
| 归档时间: |
|
| 查看次数: |
23537 次 |
| 最近记录: |