Dim MyBook As New C1Excel.C1XLBook '当前的Book Dim str As String Dim i,bi As Integer i = 0 bi = 0 Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xlsx|Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" '设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮 MyBook.load(dlg.FileName) For Each sheet As C1Excel.XLSheet In MyBook.Sheets() str = sheet.name If i = bi Then Dim ip As New Importer ip.SourcePath = dlg.FileName '指定数据文件 ip.SourceTableName = str '指定要导入的表 ip.NewTableName = str '导入后的表名 ip.Format = "Excel" '指定导入格式 MessageBox.Show(ip.SourceTableName & "\" & ip.NewTableName &"\"& ip.Format) ip.Import() i += 1 bi = i End If Next End If
|