Foxtable(狐表)用户栏目专家坐堂 → [求助]设计导入器的时候 怎么定义导入空表时不报错


  共有2610人关注过本帖树形打印复制链接

主题:[求助]设计导入器的时候 怎么定义导入空表时不报错

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/21 15:43:00 [显示全部帖子]

空表?指excel文件没有sheet?

 

stname.SelectedIndex = 0

 

改成

 

If stname.combolist = Nothing Then Return

stname.SelectedIndex = 0


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/21 15:49:00 [显示全部帖子]

贴出按钮的代码,贴出报的错误。


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/21 16:22:00 [显示全部帖子]

按钮代码

 

Dim bookname As WinForm.TextBox = e.Form.Controls("bookName")
If bookname.Value = "" Then
   
    MessageBox.show("请点击 [Excel文件] 按钮,选取Excel文件! ","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Error)
    Return
End If

Dim sheetname As WinForm.ComboBox = e.Form.Controls("sheetname")
If sheetname.SelectedValue = "" Then
    MessageBox.show("导入工作表不能为空 ! ","错误提示",MessageBoxButtons.OK,MessageBoxIcon.Error)
    Return
End If

Dim Book As New XLS.Book(bookname.text)
Dim sheet As XLS.Sheet = book.sheets(sheetname.SelectedValue)
Dim bt As WinForm.CheckBox = e.Form.Controls("标题")
'设定最大取值列
Dim maxc As WinForm.NumericComboBox = e.Form.Controls("最大列")
If maxc.value > sheet.Cols.Count Or maxc.value = 0 Then
    maxc.Value = sheet.Cols.Count
End If
Dim qsh As WinForm.NumericComboBox = e.Form.Controls("有效起始行")
Dim cblst As String
'------遍历数据-----
Dim qs As Integer = cint(qsh.Text)
For r As Integer = qs-1 To qs+6
    Dim lst As String = ""
    For c As Integer = 0 To maxc.value - 1
        Dim data As String = sheet(r,c).value
        lst = lst & data.PadLeft(8," ") & ","
    Next
    cblst = cblst & lst & "|"
Next
'-----标题-----'
Dim h As String

Dim cbl As String = ""


For c As Integer = 0 To maxc.Value -1
    h = "第" & cstr(c+1) & "列"
    If bt.Checked Then
        cbl = cbl & h & "-->" & sheet(qs-1,c).Text & "|"
    Else
        cbl = cbl & h & "|"
    End If
Next
Dim lst5r As WinForm.ListBox = e.Form.Controls("lst5r")
lst5r.ComboList = cblst
e.Form.Controls("表字段0").combolist = cbl.TrimEnd("|")

'dcl.ComboList = cbl.TrimEnd("|")


 回到顶部