以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]用对话框的方式批量导入可以实现吗? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=57392) |
-- 作者:xiaoyongxg2 -- 发布时间:2014/9/24 9:55:00 -- [求助]用对话框的方式批量导入可以实现吗? 甜老师,用对话框的方式进行批量导入excel文件,且文件名和表名都不一样,可以实现吗? |
-- 作者:有点甜 -- 发布时间:2014/9/24 9:56:00 -- 可以,看 示例2
http://www.foxtable.com/help/topics/0328.htm
|
-- 作者:xiaoyongxg2 -- 发布时间:2014/9/24 10:15:00 -- 出错了,找不到哪不对,甜老师 System.Data.OleDb.OleDbException: SELECT 子句中包含一个保留字、拼写错误或丢失的参数,或标点符号不正确。 Dim dlg As New OpenFileDialog dlg.MultiSelect = True If dlg.ShowDialog = DialogResult.OK Then For Each fl As String In dlg.FileNames Dim ip As New Importer ip.SourcePath = dlg.FileName ip.SourceTableName = fl ip.NewTableName = fl ip.Import() Next End If
|
-- 作者:Bin -- 发布时间:2014/9/24 10:18:00 -- ip.Format ="Excel" ip.SourceTableName = fl & "$"
|
-- 作者:xiaoyongxg2 -- 发布时间:2014/9/24 10:22:00 -- 是这样吗? Dim dlg As New OpenFileDialog dlg.MultiSelect = True If dlg.ShowDialog = DialogResult.OK Then For Each fl As String In dlg.FileNames Dim ip As New Importer ip.Format ="Excel" ip.SourcePath = dlg.FileName ip.SourceTableName = fl & "$" ip.NewTableName = fl ip.Import() Next End If |
-- 作者:Bin -- 发布时间:2014/9/24 10:22:00 -- 嗯. |
-- 作者:有点甜 -- 发布时间:2014/9/24 10:23:00 -- Dim dlg As New OpenFileDialog dlg.MultiSelect = True If dlg.ShowDialog = DialogResult.OK Then For Each fl As String In dlg.FileNames Dim book As new XLS.Book(fl) For Each sheet As XLS.Sheet In book.Sheets Dim ip As New Importer ip.SourcePath = dlg.FileName ip.Format = "excel" ip.SourceTableName = sheet.Name & "$" ip.NewTableName = sheet.Name ip.Import() Next Next End If |
-- 作者:xiaoyongxg2 -- 发布时间:2014/9/24 10:38:00 -- 导一个没问题,成批导还是出刚才的错误 |
-- 作者:有点甜 -- 发布时间:2014/9/24 10:42:00 -- 不可能有问题,如果有问题,就是你的excel表格不符合规范
Dim dlg As New OpenFileDialog |
-- 作者:xiaoyongxg2 -- 发布时间:2014/9/24 10:43:00 -- 如果是文件格式不规范的话,不应该会单个导入正常,批量出错啊 |