以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  导入EXCEL表格,语句怎么改  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=42748)

--  作者:zqing
--  发布时间:2013/11/20 22:03:00
--  导入EXCEL表格,语句怎么改
 我有个现成的excel表格,见
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:物料信息.xls

附件,想设置个一个“导入”按钮,单击后把我表格数据导入到foxtable空的表格里,我参考下帮助文件说明
Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Dim ip As New Importer
    ip.SourcePath = dlg.FileName \'指定数据文件
    ip.SourceTableName = "物料信息" \'指定要导入的表
    ip.NewTableName ="物料信息" \'导入后的表名
    ip.Import()
End If

上面输入代码后运行不了。。
另外,要是随便导入个excel表格到foxtable里 代码怎么写?谢谢各位大侠了!

--  作者:zqing
--  发布时间:2013/11/20 22:09:00
--  
求救啊!!!
--  作者:zqing
--  发布时间:2013/11/20 22:15:00
--  
有没有高手 帮忙帮忙下 菜鸟跪求!!!
--  作者:有点甜
--  发布时间:2013/11/20 22:18:00
--  
 代码如下

Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Dim ip As New Importer
    ip.Format = "excel"
    ip.SourcePath = dlg.FileName \'指定数据文件
    ip.SourceTableName = "物料信息$" \'指定要导入的表
    ip.NewTableName ="物料信息" \'导入后的表名
    ip.Import()
End If

--  作者:有点甜
--  发布时间:2013/11/20 22:23:00
--  
 导入任意一个excel的话,需要先打开excel获取表的名字,才能导入。

  Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" \'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Dim Book As New XLS.Book(dlg.FileName)
    For Each sheet As xls.Sheet In book.sheets
        Dim ip As New Importer
        ip.Format = "excel"
        ip.SourcePath = dlg.FileName \'指定数据文件
        ip.SourceTableName = sheet.Name & "$" \'指定要导入的表
        ip.NewTableName = sheet.Name \'导入后的表名
        ip.Import()
    Next
End If