Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:返回Excel表格中某字段的行列

1楼
tld 发表于:2024/2/21 17:23:00
老师好,下面代码是通过自定义函数寻找Excel文档中某个单元格的行与列信息

Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx;*.xlsm" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Dim ar() As String = Functions.Execute("测试", sheet, "序号")
    Output.show(ar(0) & "  " & ar(1))
End If


自定义函数代码如下  (自定义函数名为  测试)
Dim Ws As XLS.Sheet = Args (0)
Dim Key_Word As String = Args (1)'需要查找的单元格的关键字
Dim arr() As String
Dim r As Integer = Ws.Rows.Count 
Dim c As Integer = Ws.Cols.Count 
For i As Integer = 1 To r
    For j As Integer = 1 To c 
        Dim s As String = Ws (i, j).Value 
        If s = Key_Word Then
            arr(0) = r
            arr(1) = c 
            Exit For
        End If
    Next 
Next
Return arr

执行时出现错误

请老师帮忙给看下。 谢谢!
2楼
有点蓝 发表于:2024/2/21 17:28:00
Dim arr(1) As String

http://www.foxtable.com/webhelp/topics/0216.htm
共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.