情景
我正在使用 Telerik UI For Windows forms。
我在一个RadGridView上表示一个名为MarketInfo
的自定义类型:
Public NotInheritable Class MarketInfo
...
Public ReadOnly Property Participants As ReadOnlyCollection(Of ParticipantInfo)
Get
Return Me.GetParticipants()
End Get
End Property
...
End Class
它只包含文本和布尔属性,以及Participants
属性,该属性返回另一种自定义类型的集合:
Private Function GetParticipants(ByVal market As XElement) As ReadOnlyCollection(Of ParticipantInfo)
Dim participantInfoList As New List(Of ParticipantInfo)
For Each participantNode As XElement In market...<participant>
participantInfoList.Add(New ParticipantInfo(participantNode))
Next
Return New ReadOnlyCollection(Of ParticipantInfo)(participantInfoList)
End Function
这是完整的 ParticipantInfo
类:
Public NotInheritable Class ParticipantInfo
Private ReadOnly participantElement As XElement
Public ReadOnly Property Name As String
Get
Return participantElement.@name
End Get
End Property
Public ReadOnly Property Id As String
Get
Return participantElement.@id
End Get
End Property
Public ReadOnly Property Odds As String
Get
Return participantElement.@odds
End Get
End Property
Public ReadOnly Property OddsDecimal As String
Get
Return participantElement.@oddsDecimal
End Get
End Property
Public ReadOnly Property LastUpdateDate As String
Get
Return participantElement.@lastUpdateDate
End Get
End Property
Public ReadOnly Property LastUpdateTime As String
Get
Return participantElement.@lastUpdateTime
End Get
End Property
Public ReadOnly Property Handicap As String
Get
Return participantElement.@handicap
End Get
End Property
Public Sub New(ByVal participantElement As XElement)
Me.participantElement = participantElement
End Sub
Private Sub New()
End Sub
End Class
基本上,我需要导出一个ParticipantInfo
类型的集合,这个集合应该可以在Excel中表示。好的,所以在
RadGridView
中,我隐藏了Participants
列,因为它无法表示它(因为它是一个集合),然后我将该集合作为数据源加载到另一个RadGridView
中。为了更好地理解,这是结果: 问题
我的问题是我不知道如何在Excel文件(XLSX)中解释这个问题。
这是我正在尝试导出
MarketInfo
网格内容的代码:Dim exporter As New ExportToExcelML(rdg)
With exporter
.HiddenColumnOption = HiddenOption.ExportAlways
.HiddenRowOption = HiddenOption.ExportAlways
.ExportVisualSettings = True
.SheetMaxRows = ExcelMaxRows._65536
.SheetName = "xxxxxxxx"
.SummariesExportOption = SummariesOption.ExportAll
.PagingExportOption = PagingExportOption.AllPages
.FileExtension = ".xlsx"
.RadGridViewToExport = rdg
.ChildViewExportMode = ChildViewExportMode.ExportAllViews
End With
exporter.RunExport(fileName)
但是,生成的文件只包含参与者的类型名称:
...
<Data ss:Type="String">System.Collections.ObjectModel.ReadOnlyCollection`1[WilliamHillLeecher.Leecher.Types.ParticipantInfo]</Data></Cell></Row>
...
我期望看到每个MarketInfo
创建一个Excel页面,包括那些缺少的属性。
我不熟悉Excel的使用和术语,不确定如何在表格页中表示集合,我想是通过创建一个新的表格页并将其“链接”到相应的单元格来完成。
我只希望在Excel文件中表示与我的应用程序中相同的信息。
问题
使用Telerik相关库如何做到这一点?
如果不能使用Telerik库实现,那么我该如何使用其他第三方免费库实现?
(这只是说我对其他类型的建议持开放态度,但请记住我已经了解更专注于Excel的库,但无论如何我仍然不明白如何使用任何库执行相同的添加/表示集合任务...也许是由于不理解如何使用Excel UI完成此任务。)