Using cn As OleDb.OleDbConnection = New OleDb.OleDbConnection(_Connectstring.Replace("<FilePath>", ExcelFilePath))
cn.Open()
Dim sql As String = _SelectData.Replace("<TableName>", TBName)
Using ad As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, cn)
ad.Fill(ExcelDs, TBName)
End Using
End Using
If ExcelDs.Tables(TBName).Rows.Count = 0 Then
MsgBox("未找到Excel数据")
Me.ButtonOk.Enabled = False
Exit Sub
End If
'''================== 这边绑定了jg===============
Dim Exceldt As DataTable = ExcelDs.Tables(TBName)
Exceldt.TableName = "JG"
'===================移除了jg=======================
If DataAll.Tables.Contains("JG") Then
DataAll.Tables.Remove("JG")
End If
'==================下面这一段是啥意思,狐表里面怎么体现相同的做法==========================================
DataAll.Tables.Add(Exceldt.DefaultView.ToTable(False, {"工令编号", "产品料号", "机型", "清单序号", "生产数量", "物料规格", "工艺路线"}).Copy)
Dim alljgdt As DataTable = DataAll.Tables("JG")
alljgdt.Columns.Add("材质")
alljgdt.Columns.Add("料厚", GetType(Double))
alljgdt.Columns.Add("展开宽", GetType(Double))
alljgdt.Columns.Add("展开长", GetType(Double))
alljgdt.Columns.Add("设备编号")
alljgdt.Columns.Add("预排单号")
alljgdt.Columns.Add("冲剪次数", GetType(Integer))
alljgdt.Columns.Add("物料数量", GetType(Double))
alljgdt.Columns.Add("生产顺序", GetType(Integer))
alljgdt.Columns.Add("结果")
alljgdt.Columns.Add("是否有倒角")
alljgdt.Columns.Add("是否有VOB")
alljgdt.Columns.Add("序号", GetType(Integer))
alljgdt.Columns.Item("序号").SetOrdinal(0)
alljgdt.Columns.Item("设备编号").SetOrdinal(1)
alljgdt.Columns.Item("预排单号").SetOrdinal(2)
alljgdt.Columns.Item("生产顺序").SetOrdinal(3)
alljgdt.Columns.Add("刀数", GetType(Integer))
For i As Integer = 1 To 10
alljgdt.Columns.Add("模具" & i)
Next
'=========================================================================
Me.DataGridView1.DataSource = Exceldt '这一句可以放上面吧