请各位高手帮帮忙?

rutile 2003-09-04 09:44:23
正在作统计的软件,听说excel中有统计(f检验)的功能很方便,但不知如何在vb中调用,请各位帮帮忙!
谢谢!
...全文
35 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hpfeng 2003-09-04
  • 打赏
  • 举报
回复
下面的例子中调用了Excel,需引用microsoft.excel5.0.object library (com)
imports ..
Dim name As String = excelfilePath
Dim objapp As Excel.Application = New Excel.Application()
Dim objsht As Excel.Worksheet = New Excel.Worksheet()

Try
objapp.Workbooks.Open(name)
Catch e As System.Exception
Trace.WriteLine("Error On Open Excel" & e.ToString())
Return False
End Try
objsht = objapp.Worksheets(1)

Dim ds As DataSet = New DataSet()
Dim myTable As DataTable = New DataTable()
Dim myRow As DataRow

Dim rCount, cCount As Integer
Dim i, j As Integer
'''''''''''''''''''''''''''''''''''
'构建数据表
'''''''''''''''''''''''''''''''''''
For i = 1 To objsht.Columns.Count
If objsht.Cells(1, i).value = "" Then
cCount = i - 1
Exit For
End If
Dim column As DataColumn = New DataColumn()
column.DataType = objsht.Cells(1, i).GetType
column.AllowDBNull = False
column.Caption = objsht.Cells(1, i).value
column.ColumnName = objsht.Cells(1, i).value
' Add the column to the table.
myTable.Columns.Add(column)
Next
thinkingforever 2003-09-04
  • 打赏
  • 举报
回复
学习

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧