我想对datamap的项目导出EXCEL时,导出的是显示值,我根据帮助改写成以下代码,但是老报错:
无法将类型为“C1.Win.C1FlexGrid.MultiColumnDictionary”的对象强制转换为类型“Foxtable.TableDataMap”。
但是我的表中下拉的都是用的数据表。 For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To dt.Cols.Count - 1
If dt.Cols(c).DataMap Is Nothing Then
Sheet(r + 1, c).Value = dt.rows(r)(c)
Else
Dim dmp As New TableDataMap
dmp = dt.Cols(c).DataMap
Dim dr As DataRow = DataTables(dmp.DataTable).find(dmp.DisplayCol & " = '" & dt.rows(r)(c) & "'")
If dr Is Nothing Then
Sheet(r + 1, c).Value = dt.rows(r)(c)
Else
Sheet(r + 1, c).Value = dr(dmp.ValueCol)
End If
End If
Next
Next
'打开工作簿
Book.Save(dlg.FileName)