以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 提取excel文件的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=119259) |
||||
-- 作者:vincent92 -- 发布时间:2018/5/21 17:10:00 -- 提取excel文件的问题 请教一下,我做了一个按钮提取excel文件的内容,但是跳出如下字样,是什么意思呢? .NET Framework 版本:2.0.50727.4984 Foxtable 版本:2018.3.9.1 错误所在事件:窗口,窗口1,Button2,Click 详细错误信息: 索引超出了数组界限。 |
||||
-- 作者:有点甜 -- 发布时间:2018/5/21 17:13:00 -- 贴出所写代码。 [此贴子已经被作者于2018/5/21 17:13:05编辑过]
|
||||
-- 作者:vincent92 -- 发布时间:2018/5/21 17:23:00 -- Dim dlg As New OpenFileDialog dlg.MultiSelect = True If dlg.ShowDialog = DialogResult.OK Then OutPut.Show("你选择了" & dlg.FileNames.Length & "个文件, 分别是:") For Each fl As String In dlg.FileNames Output.Show(fl) Next End If For Each fl As String In dlg.FileNames Dim Book As new XLS.Book(fl) Dim Sheet As XLS.Sheet = Book.Sheets(5) Dim s As String s = filesys.GetName(fl) Dim t = s.Substring(4) Tables("AC01").StopRedraw() Dim nms() As String = {"月度","区域","渠道","品牌","年","大类","库龄","跌价"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim r As Row = Tables("AC01").AddNew() r(nms(0)) = t For m As Integer = 1 To nms.Length r(nms(m)) = Sheet(n,m-1).Value Next Next Next Tables("AC01").ResumeRedraw()
|
||||
-- 作者:有点甜 -- 发布时间:2018/5/21 17:30: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) If book.sheets.Count <= 5 Then msgbox("sheet小于6个,不能导入") Else Dim Sheet As XLS.Sheet = Book.Sheets(5) \'也可以写sheet的名字的 Dim s As String s = filesys.GetName(fl) Dim t = s.Substring(4) Tables("AC01").StopRedraw() Dim nms() As String = {"月度","区域","渠道","品牌","年","大类","库龄","跌价"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim r As Row = Tables("AC01").AddNew() r(nms(0)) = t For m As Integer = 1 To nms.Length r(nms(m)) = Sheet(n,m-1).Value Next Next End If Next End If |
||||
-- 作者:vincent92 -- 发布时间:2018/5/21 17:43:00 -- 不行啊,还是一样的对话框,我选中的excel应该都是有6个sheet的,没有问题 |
||||
-- 作者:vincent92 -- 发布时间:2018/5/21 17:47:00 --
看一下,这个是我的数据源表格,我把不想关的信息清空了,是不是我的excel有问题
|
||||
-- 作者:有点甜 -- 发布时间:2018/5/21 17:58:00 -- Dim dlg As New OpenFileDialog |
||||
-- 作者:vincent92 -- 发布时间:2018/5/21 18:05:00 -- 了解了,谢谢!!! |