在使用 datatablebuilder时发生如下错误:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
代码如下:其他的都已经注释掉,唯一保留了红色部分代码,依旧报错,
请提问这个错误是哪里产生的?
Case "下载规格表"
DataTables("成品BOM").DataCols("成品料号").RaiseDataColChanged()
Dim dtb As New DataTableBuilder("表B")
dtb.AddDef("线体",Gettype(String),20)
dtb.AddDef("成品料号",Gettype(String),20)
dtb.AddDef("成品描述",Gettype(String),50)
dtb.AddDef("规格下限",Gettype(Double))
dtb.AddDef("规格上限",Gettype(Double))
For Each v As String In DataTables("成品规格").GetValues("规格名称")
dtb.AddDef(v, Gettype(Double))
Next
dtb.Build()
'For Each v As String() In DataTables("成品规格").GetValues("线体|成品料号|成品描述")
'Dim dr1 As DataRow = DataTables("表B").AddNew()
'dr1("线体") = v(0)
'dr1("成品料号") = v(1)
'dr1("成品描述")=v(2)
'For Each dr2 As DataRow In DataTables ("成品规格").Select("线体 = '" & v(0) & "' And 成品料号 = '" & v(1) & "'")
'dr1(dr2("规格名称")) = dr2("目标规格")
'dr1("规格下限") = dr2("规格下限")
'dr1("规格上限") = dr2("规格上限")
'
'Next
'Next
'MessageBox.Show("请先维护 规格清单后下载本表,填写数据后再保存上传")
'
'MainTable=Tables("表B")
'Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
'dlg.Filter= "Excel文件|*.xls" '设置筛选器
'If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
'MainTable.SaveExcel(dlg.FileName,"sheet1") '保存文件
'End If